Merge pull request #22027 from raduciopraga/feature/aws-account-details
Added status and e-mail as labels to the AWS Account Resource
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-aws': patch
|
||||
---
|
||||
|
||||
Added status and e-mail as labels to the AWS Account Resource
|
||||
+17
-5
@@ -40,7 +40,9 @@ describe('AwsOrganizationCloudAccountProcessor', () => {
|
||||
Accounts: [
|
||||
{
|
||||
Arn: 'arn:aws:organizations::192594491037:account/o-1vl18kc5a3/957140518395',
|
||||
Name: 'testaccount',
|
||||
Name: 'Test Account',
|
||||
Email: 'aws-test-account@backstage.io',
|
||||
Status: 'ACTIVE',
|
||||
},
|
||||
],
|
||||
NextToken: undefined,
|
||||
@@ -59,7 +61,12 @@ describe('AwsOrganizationCloudAccountProcessor', () => {
|
||||
'amazonaws.com/account-id': '957140518395',
|
||||
'amazonaws.com/organization-id': 'o-1vl18kc5a3',
|
||||
},
|
||||
name: 'testaccount',
|
||||
labels: {
|
||||
'amazonaws.com/account-status': 'active',
|
||||
'amazonaws.com/account-email': 'aws-test-account@backstage.io',
|
||||
},
|
||||
name: 'test-account',
|
||||
title: 'Test Account',
|
||||
namespace: 'default',
|
||||
},
|
||||
spec: {
|
||||
@@ -79,11 +86,11 @@ describe('AwsOrganizationCloudAccountProcessor', () => {
|
||||
Accounts: [
|
||||
{
|
||||
Arn: 'arn:aws:organizations::192594491037:account/o-1vl18kc5a3/957140518395',
|
||||
Name: 'testaccount',
|
||||
Name: 'Test Account',
|
||||
},
|
||||
{
|
||||
Arn: 'arn:aws:organizations::192594491037:account/o-zzzzzzzzz/957140518395',
|
||||
Name: 'testaccount2',
|
||||
Name: 'Test Account 2',
|
||||
},
|
||||
],
|
||||
NextToken: undefined,
|
||||
@@ -103,7 +110,12 @@ describe('AwsOrganizationCloudAccountProcessor', () => {
|
||||
'amazonaws.com/account-id': '957140518395',
|
||||
'amazonaws.com/organization-id': 'o-1vl18kc5a3',
|
||||
},
|
||||
name: 'testaccount',
|
||||
labels: {
|
||||
'amazonaws.com/account-status': '',
|
||||
'amazonaws.com/account-email': '',
|
||||
},
|
||||
name: 'test-account',
|
||||
title: 'Test Account',
|
||||
namespace: 'default',
|
||||
},
|
||||
spec: {
|
||||
|
||||
+14
@@ -41,6 +41,9 @@ const ACCOUNTID_ANNOTATION = 'amazonaws.com/account-id';
|
||||
const ARN_ANNOTATION = 'amazonaws.com/arn';
|
||||
const ORGANIZATION_ANNOTATION = 'amazonaws.com/organization-id';
|
||||
|
||||
const ACCOUNT_STATUS_LABEL = 'amazonaws.com/account-status';
|
||||
const ACCOUNT_EMAIL_LABEL = 'amazonaws.com/account-email';
|
||||
|
||||
/**
|
||||
* A processor for ingesting AWS Accounts from AWS Organizations.
|
||||
*
|
||||
@@ -123,6 +126,10 @@ export class AwsOrganizationCloudAccountProcessor implements CatalogProcessor {
|
||||
.replace(/[^a-zA-Z0-9\-]/g, '-');
|
||||
}
|
||||
|
||||
private normalizeAccountStatus(name: string): string {
|
||||
return name.toLocaleLowerCase('en-US');
|
||||
}
|
||||
|
||||
private extractInformationFromArn(arn: string): {
|
||||
accountId: string;
|
||||
organizationId: string;
|
||||
@@ -165,7 +172,14 @@ export class AwsOrganizationCloudAccountProcessor implements CatalogProcessor {
|
||||
[ARN_ANNOTATION]: account.Arn || '',
|
||||
[ORGANIZATION_ANNOTATION]: organizationId,
|
||||
},
|
||||
labels: {
|
||||
[ACCOUNT_EMAIL_LABEL]: account.Email || '',
|
||||
[ACCOUNT_STATUS_LABEL]: this.normalizeAccountStatus(
|
||||
account.Status || '',
|
||||
),
|
||||
},
|
||||
name: this.normalizeName(account.Name || ''),
|
||||
title: account.Name || '',
|
||||
namespace: 'default',
|
||||
},
|
||||
spec: {
|
||||
|
||||
Reference in New Issue
Block a user