@backstage/plugin-catalog-backend-module-aws 0.0.0-nightly-20220221022454 → 0.0.0-nightly-20220224022833
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-aws
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20220224022833
|
|
4
|
+
|
|
4
5
|
### Minor Changes
|
|
5
6
|
|
|
6
7
|
- 25e97e7242: Added this new catalog module, initially containing only the
|
|
7
8
|
`AwsOrganizationCloudAccountProcessor`.
|
|
8
|
-
|
|
9
|
+
|
|
9
10
|
Note that this was moved over from the catalog backend itself, and therefore is
|
|
10
11
|
no longer part of its builtin set of processors. If you were using this
|
|
11
12
|
processor, through making use of the location type `aws-cloud-accounts` and/or
|
|
12
13
|
using the configuration key `catalog.processors.awsOrganization`, you will from
|
|
13
14
|
now on have to add the processor manually to your catalog.
|
|
14
|
-
|
|
15
|
+
|
|
15
16
|
First, add the `@backstage/plugin-catalog-backend-module-aws` dependency to your
|
|
16
17
|
`packages/backend` package.
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
Then, in `packages/backend/src/plugins/catalog.ts`:
|
|
19
|
-
|
|
20
|
+
|
|
20
21
|
```diff
|
|
21
22
|
+import { AwsOrganizationCloudAccountProcessor } from '@backstage/plugin-catalog-backend-module-aws';
|
|
22
|
-
|
|
23
|
+
|
|
23
24
|
export default async function createPlugin(
|
|
24
25
|
env: PluginEnvironment,
|
|
25
26
|
): Promise<Router> {
|
|
@@ -36,5 +37,5 @@
|
|
|
36
37
|
### Patch Changes
|
|
37
38
|
|
|
38
39
|
- Updated dependencies
|
|
39
|
-
- @backstage/plugin-catalog-backend@0.0.0-nightly-
|
|
40
|
-
- @backstage/catalog-model@0.0.0-nightly-
|
|
40
|
+
- @backstage/plugin-catalog-backend@0.0.0-nightly-20220224022833
|
|
41
|
+
- @backstage/catalog-model@0.0.0-nightly-20220224022833
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/awsOrganization/config.ts","../src/processors/AwsOrganizationCloudAccountProcessor.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\n/**\n * The configuration parameters for a single AWS Organization Processor\n */\nexport type AwsOrganizationProviderConfig = {\n /**\n * The role to assume for the processor.\n */\n roleArn?: string;\n};\n\nexport function readAwsOrganizationConfig(\n config: Config,\n): AwsOrganizationProviderConfig {\n const providerConfig = config.getOptionalConfig('provider');\n\n const roleArn = providerConfig?.getOptionalString('roleArn');\n return {\n roleArn,\n };\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/awsOrganization/config.ts","../src/processors/AwsOrganizationCloudAccountProcessor.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\n/**\n * The configuration parameters for a single AWS Organization Processor\n */\nexport type AwsOrganizationProviderConfig = {\n /**\n * The role to assume for the processor.\n */\n roleArn?: string;\n};\n\nexport function readAwsOrganizationConfig(\n config: Config,\n): AwsOrganizationProviderConfig {\n const providerConfig = config.getOptionalConfig('provider');\n\n const roleArn = providerConfig?.getOptionalString('roleArn');\n return {\n roleArn,\n };\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ResourceEntityV1alpha1 } from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n results,\n} from '@backstage/plugin-catalog-backend';\nimport AWS, { Credentials, Organizations } from 'aws-sdk';\nimport { Account, ListAccountsResponse } from 'aws-sdk/clients/organizations';\nimport { Logger } from 'winston';\nimport {\n AwsOrganizationProviderConfig,\n readAwsOrganizationConfig,\n} from '../awsOrganization/config';\n\nconst AWS_ORGANIZATION_REGION = 'us-east-1';\nconst LOCATION_TYPE = 'aws-cloud-accounts';\n\nconst ACCOUNTID_ANNOTATION = 'amazonaws.com/account-id';\nconst ARN_ANNOTATION = 'amazonaws.com/arn';\nconst ORGANIZATION_ANNOTATION = 'amazonaws.com/organization-id';\n\n/**\n * A processor for ingesting AWS Accounts from AWS Organizations.\n *\n * If custom authentication is needed, it can be achieved by configuring the\n * global AWS.credentials object.\n *\n * @public\n */\nexport class AwsOrganizationCloudAccountProcessor implements CatalogProcessor {\n private readonly organizations: Organizations;\n private readonly provider: AwsOrganizationProviderConfig;\n\n static fromConfig(config: Config, options: { logger: Logger }) {\n const c = config.getOptionalConfig('catalog.processors.awsOrganization');\n return new AwsOrganizationCloudAccountProcessor({\n ...options,\n provider: c ? readAwsOrganizationConfig(c) : {},\n });\n }\n\n private static buildCredentials(\n config: AwsOrganizationProviderConfig,\n ): Credentials | undefined {\n const roleArn = config.roleArn;\n if (!roleArn) {\n return undefined;\n }\n\n return new AWS.ChainableTemporaryCredentials({\n params: {\n RoleSessionName: 'backstage-aws-organization-processor',\n RoleArn: roleArn,\n },\n });\n }\n\n private constructor(options: { provider: AwsOrganizationProviderConfig }) {\n this.provider = options.provider;\n const credentials = AwsOrganizationCloudAccountProcessor.buildCredentials(\n this.provider,\n );\n this.organizations = new AWS.Organizations({\n credentials,\n region: AWS_ORGANIZATION_REGION,\n }); // Only available in us-east-1\n }\n\n getProcessorName(): string {\n return 'AwsOrganizationCloudAccountProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== LOCATION_TYPE) {\n return false;\n }\n\n (await this.getAwsAccounts())\n .map(account => this.mapAccountToComponent(account))\n .filter(entity => {\n if (location.target !== '') {\n if (entity.metadata.annotations) {\n return (\n entity.metadata.annotations[ORGANIZATION_ANNOTATION] ===\n location.target\n );\n }\n return false;\n }\n return true;\n })\n .forEach(entity => {\n emit(results.entity(location, entity));\n });\n\n return true;\n }\n\n private normalizeName(name: string): string {\n return name\n .trim()\n .toLocaleLowerCase('en-US')\n .replace(/[^a-zA-Z0-9\\-]/g, '-');\n }\n\n private extractInformationFromArn(arn: string): {\n accountId: string;\n organizationId: string;\n } {\n const parts = arn.split('/');\n\n return {\n accountId: parts[parts.length - 1],\n organizationId: parts[parts.length - 2],\n };\n }\n\n private async getAwsAccounts(): Promise<Account[]> {\n let awsAccounts: Account[] = [];\n let isInitialAttempt = true;\n let nextToken = undefined;\n while (isInitialAttempt || nextToken) {\n isInitialAttempt = false;\n const orgAccounts: ListAccountsResponse = await this.organizations\n .listAccounts({ NextToken: nextToken })\n .promise();\n if (orgAccounts.Accounts) {\n awsAccounts = awsAccounts.concat(orgAccounts.Accounts);\n }\n nextToken = orgAccounts.NextToken;\n }\n\n return awsAccounts;\n }\n\n private mapAccountToComponent(account: Account): ResourceEntityV1alpha1 {\n const { accountId, organizationId } = this.extractInformationFromArn(\n account.Arn as string,\n );\n return {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'Resource',\n metadata: {\n annotations: {\n [ACCOUNTID_ANNOTATION]: accountId,\n [ARN_ANNOTATION]: account.Arn || '',\n [ORGANIZATION_ANNOTATION]: organizationId,\n },\n name: this.normalizeName(account.Name || ''),\n namespace: 'default',\n },\n spec: {\n type: 'cloud-account',\n owner: 'unknown',\n },\n };\n }\n}\n"],"names":["AWS","results"],"mappings":";;;;;;;;;;;mCA6BE,QAC+B;AAC/B,QAAM,iBAAiB,OAAO,kBAAkB;AAEhD,QAAM,UAAU,iDAAgB,kBAAkB;AAClD,SAAO;AAAA,IACL;AAAA;AAAA;;ACHJ,MAAM,0BAA0B;AAChC,MAAM,gBAAgB;AAEtB,MAAM,uBAAuB;AAC7B,MAAM,iBAAiB;AACvB,MAAM,0BAA0B;2CAU8C;AAAA,SAIrE,WAAW,QAAgB,SAA6B;AAC7D,UAAM,IAAI,OAAO,kBAAkB;AACnC,WAAO,IAAI,qCAAqC;AAAA,SAC3C;AAAA,MACH,UAAU,IAAI,0BAA0B,KAAK;AAAA;AAAA;AAAA,SAIlC,iBACb,Q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sBAAc,YAAY,OAAO,YAAY;AAAA;AAE/C,kBAAY,YAAY;AAAA;AAG1B,WAAO;AAAA;AAAA,EAGD,sBAAsB,SAA0C;AACtE,UAAM,EAAE,WAAW,mBAAmB,KAAK,0BACzC,QAAQ;AAEV,WAAO;AAAA,MACL,YAAY;AAAA,MACZ,MAAM;AAAA,MACN,UAAU;AAAA,QACR,aAAa;AAAA,WACV,uBAAuB;AAAA,WACvB,iBAAiB,QAAQ,OAAO;AAAA,WAChC,0BAA0B;AAAA;AAAA,QAE7B,MAAM,KAAK,cAAc,QAAQ,QAAQ;AAAA,QACzC,WAAW;AAAA;AAAA,MAEb,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,OAAO;AAAA;AAAA;AAAA;AAAA;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { LocationSpec } from '@backstage/catalog-model';
|
|
2
1
|
import { Config } from '@backstage/config';
|
|
3
|
-
import { CatalogProcessor, CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
|
|
2
|
+
import { CatalogProcessor, LocationSpec, CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
|
|
4
3
|
import { Logger } from 'winston';
|
|
5
4
|
|
|
6
5
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-backend-module-aws",
|
|
3
3
|
"description": "A Backstage catalog backend module that helps integrate towards AWS",
|
|
4
|
-
"version": "0.0.0-nightly-
|
|
4
|
+
"version": "0.0.0-nightly-20220224022833",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"start": "backstage-cli package start"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@backstage/catalog-model": "^0.0.0-nightly-
|
|
36
|
+
"@backstage/catalog-model": "^0.0.0-nightly-20220224022833",
|
|
37
37
|
"@backstage/config": "^0.1.14",
|
|
38
38
|
"@backstage/errors": "^0.2.1",
|
|
39
|
-
"@backstage/plugin-catalog-backend": "^0.0.0-nightly-
|
|
39
|
+
"@backstage/plugin-catalog-backend": "^0.0.0-nightly-20220224022833",
|
|
40
40
|
"@backstage/types": "^0.1.2",
|
|
41
41
|
"aws-sdk": "^2.840.0",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
43
43
|
"winston": "^3.2.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@backstage/cli": "^0.0.0-nightly-
|
|
46
|
+
"@backstage/cli": "^0.0.0-nightly-20220224022833",
|
|
47
47
|
"@types/lodash": "^4.14.151",
|
|
48
48
|
"aws-sdk-mock": "^5.2.1"
|
|
49
49
|
},
|