Added status and e-mail as labels to the AWS Account Resource

Signed-off-by: Radu Ciopraga <1442639+raduciopraga@users.noreply.github.com>
This commit is contained in:
Radu Ciopraga
2023-12-26 12:36:12 +01:00
parent 0533661a95
commit 22e88d079c
3 changed files with 36 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-aws': patch
---
Added status and e-mail as labels to the AWS Account Resource
@@ -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: {
@@ -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: {