@backstage/plugin-catalog-backend-module-aws 0.2.9-next.2 → 0.3.1-next.0
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 +41 -0
- package/alpha/package.json +1 -1
- package/dist/index.cjs.js +43 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +28 -3
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-aws
|
|
2
2
|
|
|
3
|
+
## 0.3.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-common@0.19.9-next.0
|
|
9
|
+
- @backstage/integration@1.7.1
|
|
10
|
+
- @backstage/integration-aws-node@0.1.7
|
|
11
|
+
- @backstage/backend-plugin-api@0.6.7-next.0
|
|
12
|
+
- @backstage/backend-tasks@0.5.12-next.0
|
|
13
|
+
- @backstage/catalog-model@1.4.3
|
|
14
|
+
- @backstage/config@1.1.1
|
|
15
|
+
- @backstage/errors@1.2.3
|
|
16
|
+
- @backstage/types@1.1.1
|
|
17
|
+
- @backstage/plugin-catalog-common@1.0.17
|
|
18
|
+
- @backstage/plugin-catalog-node@1.4.8-next.0
|
|
19
|
+
- @backstage/plugin-kubernetes-common@0.7.1-next.0
|
|
20
|
+
|
|
21
|
+
## 0.3.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- 5abc2fd4d6: AwsEksClusterProcessor supports Entity callback function and passes in region when initialize EKS cluster
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 890e3b5ad4: Make sure to include the error message when ingestion fails
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- @backstage/backend-tasks@0.5.11
|
|
32
|
+
- @backstage/backend-common@0.19.8
|
|
33
|
+
- @backstage/integration@1.7.1
|
|
34
|
+
- @backstage/plugin-catalog-node@1.4.7
|
|
35
|
+
- @backstage/catalog-model@1.4.3
|
|
36
|
+
- @backstage/errors@1.2.3
|
|
37
|
+
- @backstage/plugin-kubernetes-common@0.7.0
|
|
38
|
+
- @backstage/backend-plugin-api@0.6.6
|
|
39
|
+
- @backstage/config@1.1.1
|
|
40
|
+
- @backstage/integration-aws-node@0.1.7
|
|
41
|
+
- @backstage/types@1.1.1
|
|
42
|
+
- @backstage/plugin-catalog-common@1.0.17
|
|
43
|
+
|
|
3
44
|
## 0.2.9-next.2
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var pluginKubernetesCommon = require('@backstage/plugin-kubernetes-common');
|
|
6
5
|
var clientEks = require('@aws-sdk/client-eks');
|
|
7
6
|
var integrationAwsNode = require('@backstage/integration-aws-node');
|
|
7
|
+
var pluginKubernetesCommon = require('@backstage/plugin-kubernetes-common');
|
|
8
8
|
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
9
9
|
var clientOrganizations = require('@aws-sdk/client-organizations');
|
|
10
10
|
var errors = require('@backstage/errors');
|
|
@@ -20,33 +20,60 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
20
20
|
|
|
21
21
|
var limiterFactory__default = /*#__PURE__*/_interopDefaultLegacy(limiterFactory);
|
|
22
22
|
|
|
23
|
+
const ANNOTATION_AWS_ACCOUNT_ID = "amazonaws.com/account-id";
|
|
24
|
+
const ANNOTATION_AWS_ARN = "amazonaws.com/arn";
|
|
25
|
+
|
|
26
|
+
const defaultEksClusterEntityTransformer = async (cluster, accountId) => {
|
|
27
|
+
const { arn, endpoint, certificateAuthority, name } = cluster;
|
|
28
|
+
return {
|
|
29
|
+
apiVersion: "backstage.io/v1alpha1",
|
|
30
|
+
kind: "Resource",
|
|
31
|
+
metadata: {
|
|
32
|
+
annotations: {
|
|
33
|
+
[ANNOTATION_AWS_ACCOUNT_ID]: accountId,
|
|
34
|
+
[ANNOTATION_AWS_ARN]: arn || "",
|
|
35
|
+
[pluginKubernetesCommon.ANNOTATION_KUBERNETES_API_SERVER]: endpoint || "",
|
|
36
|
+
[pluginKubernetesCommon.ANNOTATION_KUBERNETES_API_SERVER_CA]: (certificateAuthority == null ? void 0 : certificateAuthority.data) || "",
|
|
37
|
+
[pluginKubernetesCommon.ANNOTATION_KUBERNETES_AUTH_PROVIDER]: "aws"
|
|
38
|
+
},
|
|
39
|
+
name: normalizeName(name),
|
|
40
|
+
namespace: "default"
|
|
41
|
+
},
|
|
42
|
+
spec: {
|
|
43
|
+
type: "kubernetes-cluster",
|
|
44
|
+
owner: "unknown"
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
function normalizeName(name) {
|
|
49
|
+
return name.trim().toLocaleLowerCase("en-US").replace(/[^a-zA-Z0-9\-]/g, "-");
|
|
50
|
+
}
|
|
51
|
+
|
|
23
52
|
var __defProp$1 = Object.defineProperty;
|
|
24
53
|
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
25
54
|
var __publicField$1 = (obj, key, value) => {
|
|
26
55
|
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
27
56
|
return value;
|
|
28
57
|
};
|
|
29
|
-
const ACCOUNTID_ANNOTATION$1 = "amazonaws.com/account-id";
|
|
30
|
-
const ARN_ANNOTATION$1 = "amazonaws.com/arn";
|
|
31
58
|
class AwsEKSClusterProcessor {
|
|
32
59
|
constructor(options) {
|
|
33
60
|
__publicField$1(this, "credentialsFactory");
|
|
34
61
|
__publicField$1(this, "credentialsManager");
|
|
62
|
+
__publicField$1(this, "clusterEntityTransformer");
|
|
35
63
|
this.credentialsFactory = options.credentialsFactory;
|
|
36
64
|
this.credentialsManager = options.credentialsManager;
|
|
65
|
+
this.clusterEntityTransformer = options.clusterEntityTransformer || defaultEksClusterEntityTransformer;
|
|
37
66
|
}
|
|
38
|
-
static fromConfig(configRoot) {
|
|
67
|
+
static fromConfig(configRoot, options) {
|
|
39
68
|
const awsCredentaislManager = integrationAwsNode.DefaultAwsCredentialsManager.fromConfig(configRoot);
|
|
40
69
|
return new AwsEKSClusterProcessor({
|
|
41
|
-
credentialsManager: awsCredentaislManager
|
|
70
|
+
credentialsManager: awsCredentaislManager,
|
|
71
|
+
...options
|
|
42
72
|
});
|
|
43
73
|
}
|
|
44
74
|
getProcessorName() {
|
|
45
75
|
return "aws-eks";
|
|
46
76
|
}
|
|
47
|
-
normalizeName(name) {
|
|
48
|
-
return name.trim().toLocaleLowerCase("en-US").replace(/[^a-zA-Z0-9\-]/g, "-");
|
|
49
|
-
}
|
|
50
77
|
async readLocation(location, _optional, emit) {
|
|
51
78
|
if (location.type !== "aws-eks") {
|
|
52
79
|
return false;
|
|
@@ -68,35 +95,20 @@ class AwsEKSClusterProcessor {
|
|
|
68
95
|
}
|
|
69
96
|
const eksClient = new clientEks.EKS({
|
|
70
97
|
credentials,
|
|
71
|
-
credentialDefaultProvider: providerFunction
|
|
98
|
+
credentialDefaultProvider: providerFunction,
|
|
99
|
+
region
|
|
72
100
|
});
|
|
73
101
|
const clusters = await eksClient.listClusters({});
|
|
74
102
|
if (clusters.clusters === void 0) {
|
|
75
103
|
return true;
|
|
76
104
|
}
|
|
77
105
|
const results = clusters.clusters.map((cluster) => eksClient.describeCluster({ name: cluster })).map(async (describedClusterPromise) => {
|
|
78
|
-
var _a;
|
|
79
106
|
const describedCluster = await describedClusterPromise;
|
|
80
107
|
if (describedCluster.cluster) {
|
|
81
|
-
const entity =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
annotations: {
|
|
86
|
-
[ACCOUNTID_ANNOTATION$1]: accountId,
|
|
87
|
-
[ARN_ANNOTATION$1]: describedCluster.cluster.arn || "",
|
|
88
|
-
[pluginKubernetesCommon.ANNOTATION_KUBERNETES_API_SERVER]: describedCluster.cluster.endpoint || "",
|
|
89
|
-
[pluginKubernetesCommon.ANNOTATION_KUBERNETES_API_SERVER_CA]: ((_a = describedCluster.cluster.certificateAuthority) == null ? void 0 : _a.data) || "",
|
|
90
|
-
[pluginKubernetesCommon.ANNOTATION_KUBERNETES_AUTH_PROVIDER]: "aws"
|
|
91
|
-
},
|
|
92
|
-
name: this.normalizeName(describedCluster.cluster.name),
|
|
93
|
-
namespace: "default"
|
|
94
|
-
},
|
|
95
|
-
spec: {
|
|
96
|
-
type: "kubernetes-cluster",
|
|
97
|
-
owner: "unknown"
|
|
98
|
-
}
|
|
99
|
-
};
|
|
108
|
+
const entity = await this.clusterEntityTransformer(
|
|
109
|
+
describedCluster.cluster,
|
|
110
|
+
accountId
|
|
111
|
+
);
|
|
100
112
|
emit({
|
|
101
113
|
type: "entity",
|
|
102
114
|
entity,
|
|
@@ -269,6 +281,8 @@ class AwsS3DiscoveryProcessor {
|
|
|
269
281
|
}
|
|
270
282
|
|
|
271
283
|
exports.AwsS3EntityProvider = AwsS3EntityProvider.AwsS3EntityProvider;
|
|
284
|
+
exports.ANNOTATION_AWS_ACCOUNT_ID = ANNOTATION_AWS_ACCOUNT_ID;
|
|
285
|
+
exports.ANNOTATION_AWS_ARN = ANNOTATION_AWS_ARN;
|
|
272
286
|
exports.AwsEKSClusterProcessor = AwsEKSClusterProcessor;
|
|
273
287
|
exports.AwsOrganizationCloudAccountProcessor = AwsOrganizationCloudAccountProcessor;
|
|
274
288
|
exports.AwsS3DiscoveryProcessor = AwsS3DiscoveryProcessor;
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/processors/AwsEKSClusterProcessor.ts","../src/awsOrganization/config.ts","../src/processors/AwsOrganizationCloudAccountProcessor.ts","../src/processors/AwsS3DiscoveryProcessor.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {\n CatalogProcessor,\n CatalogProcessorEmit,\n} from '@backstage/plugin-catalog-node';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport {\n ANNOTATION_KUBERNETES_API_SERVER,\n ANNOTATION_KUBERNETES_API_SERVER_CA,\n ANNOTATION_KUBERNETES_AUTH_PROVIDER,\n} from '@backstage/plugin-kubernetes-common';\nimport { EKS } from '@aws-sdk/client-eks';\nimport { AWSCredentialFactory } from '../types';\nimport { AwsCredentialIdentity, Provider } from '@aws-sdk/types';\nimport {\n AwsCredentialsManager,\n DefaultAwsCredentialsManager,\n} from '@backstage/integration-aws-node';\nimport { Config } from '@backstage/config';\n\nconst ACCOUNTID_ANNOTATION: string = 'amazonaws.com/account-id';\nconst ARN_ANNOTATION: string = 'amazonaws.com/arn';\n\n/**\n * A processor for automatic discovery of resources from EKS clusters. Handles the\n * `aws-eks` location type, and target accounts/regions of the form\n * `<accountId>/<region>`.\n *\n * @public\n */\nexport class AwsEKSClusterProcessor implements CatalogProcessor {\n private credentialsFactory?: AWSCredentialFactory;\n private credentialsManager?: AwsCredentialsManager;\n\n static fromConfig(configRoot: Config): AwsEKSClusterProcessor {\n const awsCredentaislManager =\n DefaultAwsCredentialsManager.fromConfig(configRoot);\n return new AwsEKSClusterProcessor({\n credentialsManager: awsCredentaislManager,\n });\n }\n\n constructor(options: {\n credentialsFactory?: AWSCredentialFactory;\n credentialsManager?: AwsCredentialsManager;\n }) {\n this.credentialsFactory = options.credentialsFactory;\n this.credentialsManager = options.credentialsManager;\n }\n\n getProcessorName(): string {\n return 'aws-eks';\n }\n\n normalizeName(name: string): string {\n return name\n .trim()\n .toLocaleLowerCase('en-US')\n .replace(/[^a-zA-Z0-9\\-]/g, '-');\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'aws-eks') {\n return false;\n }\n\n // location target is of format \"account-id/region\"\n const [accountId, region] = location.target.split('/');\n\n if (!accountId || !region) {\n throw new Error(\n 'AWS EKS location specified without account or region information',\n );\n }\n\n let credentials: AwsCredentialIdentity | undefined;\n\n if (this.credentialsFactory) {\n credentials = await this.credentialsFactory(accountId);\n }\n\n let providerFunction: (() => Provider<AwsCredentialIdentity>) | undefined;\n if (this.credentialsManager) {\n const credentialsProvider =\n await this.credentialsManager.getCredentialProvider({ accountId });\n providerFunction = () => credentialsProvider.sdkCredentialProvider;\n }\n\n const eksClient = new EKS({\n credentials,\n credentialDefaultProvider: providerFunction,\n });\n const clusters = await eksClient.listClusters({});\n if (clusters.clusters === undefined) {\n return true;\n }\n\n const results = clusters.clusters\n .map(cluster => eksClient.describeCluster({ name: cluster }))\n .map(async describedClusterPromise => {\n const describedCluster = await describedClusterPromise;\n if (describedCluster.cluster) {\n const entity = {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'Resource',\n metadata: {\n annotations: {\n [ACCOUNTID_ANNOTATION]: accountId,\n [ARN_ANNOTATION]: describedCluster.cluster.arn || '',\n [ANNOTATION_KUBERNETES_API_SERVER]:\n describedCluster.cluster.endpoint || '',\n [ANNOTATION_KUBERNETES_API_SERVER_CA]:\n describedCluster.cluster.certificateAuthority?.data || '',\n [ANNOTATION_KUBERNETES_AUTH_PROVIDER]: 'aws',\n },\n name: this.normalizeName(describedCluster.cluster.name as string),\n namespace: 'default',\n },\n spec: {\n type: 'kubernetes-cluster',\n owner: 'unknown',\n },\n };\n emit({\n type: 'entity',\n entity,\n location,\n });\n }\n });\n await Promise.all(results);\n return true;\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 { 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 processingResult,\n} from '@backstage/plugin-catalog-node';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport {\n Account,\n ListAccountsResponse,\n Organizations,\n} from '@aws-sdk/client-organizations';\nimport { Logger } from 'winston';\nimport { readAwsOrganizationConfig } from '../awsOrganization/config';\nimport {\n AwsCredentialProvider,\n DefaultAwsCredentialsManager,\n} from '@backstage/integration-aws-node';\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 logger: Logger;\n\n static async fromConfig(config: Config, options: { logger: Logger }) {\n const c = config.getOptionalConfig('catalog.processors.awsOrganization');\n const orgConfig = c ? readAwsOrganizationConfig(c) : undefined;\n const awsCredentialsManager =\n DefaultAwsCredentialsManager.fromConfig(config);\n const credProvider = await awsCredentialsManager.getCredentialProvider({\n arn: orgConfig?.roleArn,\n });\n return new AwsOrganizationCloudAccountProcessor(\n credProvider,\n options.logger,\n );\n }\n\n private constructor(\n private readonly credProvider: AwsCredentialProvider,\n logger: Logger,\n ) {\n this.logger = logger?.child({\n target: this.getProcessorName(),\n });\n this.organizations = new Organizations({\n credentialDefaultProvider: () => this.credProvider.sdkCredentialProvider,\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 this.logger?.info('Discovering AWS Organization Account objects');\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(processingResult.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 =\n await this.organizations.listAccounts({ NextToken: nextToken });\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","/*\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 { UrlReader } from '@backstage/backend-common';\nimport { isError } from '@backstage/errors';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n CatalogProcessorParser,\n processingResult,\n} from '@backstage/plugin-catalog-node';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport limiterFactory from 'p-limit';\n\n/**\n * A processor for automatic discovery of entities from S3 buckets. Handles the\n * `s3-discovery` location type, and target bucket URLs e.g. on the form\n * `https://testbucket.s3.us-east-2.amazonaws.com`.\n *\n * @public\n * @deprecated Use the `AwsS3EntityProvider` instead (see https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-aws/CHANGELOG.md#014).\n */\nexport class AwsS3DiscoveryProcessor implements CatalogProcessor {\n constructor(private readonly reader: UrlReader) {}\n\n getProcessorName(): string {\n return 'AwsS3DiscoveryProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n optional: boolean,\n emit: CatalogProcessorEmit,\n parser: CatalogProcessorParser,\n ): Promise<boolean> {\n if (location.type !== 's3-discovery') {\n return false;\n }\n\n try {\n const output = await this.doRead(location.target);\n for (const item of output) {\n for await (const parseResult of parser({\n data: item.data,\n location: { type: location.type, target: item.url },\n })) {\n emit(parseResult);\n }\n }\n } catch (error) {\n const message = `Unable to read ${location.type}, ${error}`;\n\n if (isError(error) && error.name === 'NotFoundError') {\n if (!optional) {\n emit(processingResult.notFoundError(location, message));\n }\n } else {\n emit(processingResult.generalError(location, message));\n }\n }\n return true;\n }\n\n private async doRead(\n location: string,\n ): Promise<{ data: Buffer; url: string }[]> {\n const limiter = limiterFactory(5);\n const response = await this.reader.readTree(location);\n const responseFiles = await response.files();\n const output = responseFiles.map(async file => ({\n url: file.path,\n data: await limiter(file.content),\n }));\n return Promise.all(output);\n }\n}\n"],"names":["ACCOUNTID_ANNOTATION","ARN_ANNOTATION","__publicField","DefaultAwsCredentialsManager","EKS","ANNOTATION_KUBERNETES_API_SERVER","ANNOTATION_KUBERNETES_API_SERVER_CA","ANNOTATION_KUBERNETES_AUTH_PROVIDER","Organizations","processingResult","isError","limiterFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAMA,sBAA+B,GA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;AAAA,GACT;AAAA,EAEA,MAAc,OACZ,QAC0C,EAAA;AAC1C,IAAM,MAAA,OAAA,GAAUE,mCAAe,CAAC,CAAA,CAAA;AAChC,IAAA,MAAM,QAAW,GAAA,MAAM,IAAK,CAAA,MAAA,CAAO,SAAS,QAAQ,CAAA,CAAA;AACpD,IAAM,MAAA,aAAA,GAAgB,MAAM,QAAA,CAAS,KAAM,EAAA,CAAA;AAC3C,IAAA,MAAM,MAAS,GAAA,aAAA,CAAc,GAAI,CAAA,OAAM,IAAS,MAAA;AAAA,MAC9C,KAAK,IAAK,CAAA,IAAA;AAAA,MACV,IAAM,EAAA,MAAM,OAAQ,CAAA,IAAA,CAAK,OAAO,CAAA;AAAA,KAChC,CAAA,CAAA,CAAA;AACF,IAAO,OAAA,OAAA,CAAQ,IAAI,MAAM,CAAA,CAAA;AAAA,GAC3B;AACF;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/constants.ts","../src/lib/defaultTransformers.ts","../src/processors/AwsEKSClusterProcessor.ts","../src/awsOrganization/config.ts","../src/processors/AwsOrganizationCloudAccountProcessor.ts","../src/processors/AwsS3DiscoveryProcessor.ts"],"sourcesContent":["/*\n * Copyright 2023 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\n/**\n * Annotation for specifying AWS account id\n *\n * @public\n */\nexport const ANNOTATION_AWS_ACCOUNT_ID: string = 'amazonaws.com/account-id';\n/**\n * Annotation for specifying AWS arn\n *\n * @public\n */\nexport const ANNOTATION_AWS_ARN: string = 'amazonaws.com/arn';\n","/*\n * Copyright 2023 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 */\nimport { type Cluster } from '@aws-sdk/client-eks';\nimport {\n ANNOTATION_KUBERNETES_API_SERVER,\n ANNOTATION_KUBERNETES_API_SERVER_CA,\n ANNOTATION_KUBERNETES_AUTH_PROVIDER,\n} from '@backstage/plugin-kubernetes-common';\nimport type { EksClusterEntityTransformer } from '../processors/types';\nimport { ANNOTATION_AWS_ACCOUNT_ID, ANNOTATION_AWS_ARN } from '../constants';\n\n/**\n * Default transformer for EKS Cluster to Resource Entity\n * @public\n */\nexport const defaultEksClusterEntityTransformer: EksClusterEntityTransformer =\n async (cluster: Cluster, accountId: string) => {\n const { arn, endpoint, certificateAuthority, name } = cluster;\n return {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'Resource',\n metadata: {\n annotations: {\n [ANNOTATION_AWS_ACCOUNT_ID]: accountId,\n [ANNOTATION_AWS_ARN]: arn || '',\n [ANNOTATION_KUBERNETES_API_SERVER]: endpoint || '',\n [ANNOTATION_KUBERNETES_API_SERVER_CA]:\n certificateAuthority?.data || '',\n [ANNOTATION_KUBERNETES_AUTH_PROVIDER]: 'aws',\n },\n name: normalizeName(name as string),\n namespace: 'default',\n },\n spec: {\n type: 'kubernetes-cluster',\n owner: 'unknown',\n },\n };\n };\n\nfunction normalizeName(name: string): string {\n return name\n .trim()\n .toLocaleLowerCase('en-US')\n .replace(/[^a-zA-Z0-9\\-]/g, '-');\n}\n","/*\n * Copyright 2022 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 {\n CatalogProcessor,\n CatalogProcessorEmit,\n} from '@backstage/plugin-catalog-node';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport { EKS } from '@aws-sdk/client-eks';\nimport { AWSCredentialFactory } from '../types';\nimport { AwsCredentialIdentity, Provider } from '@aws-sdk/types';\nimport {\n AwsCredentialsManager,\n DefaultAwsCredentialsManager,\n} from '@backstage/integration-aws-node';\nimport { Config } from '@backstage/config';\n\nimport type { EksClusterEntityTransformer } from './types';\nimport { defaultEksClusterEntityTransformer } from '../lib';\n\n/**\n * A processor for automatic discovery of resources from EKS clusters. Handles the\n * `aws-eks` location type, and target accounts/regions of the form\n * `<accountId>/<region>`.\n *\n * @public\n */\nexport class AwsEKSClusterProcessor implements CatalogProcessor {\n private credentialsFactory?: AWSCredentialFactory;\n private credentialsManager?: AwsCredentialsManager;\n private readonly clusterEntityTransformer: EksClusterEntityTransformer;\n\n static fromConfig(\n configRoot: Config,\n options?: {\n clusterEntityTransformer?: EksClusterEntityTransformer;\n },\n ): AwsEKSClusterProcessor {\n const awsCredentaislManager =\n DefaultAwsCredentialsManager.fromConfig(configRoot);\n return new AwsEKSClusterProcessor({\n credentialsManager: awsCredentaislManager,\n ...options,\n });\n }\n\n constructor(options: {\n credentialsFactory?: AWSCredentialFactory;\n credentialsManager?: AwsCredentialsManager;\n clusterEntityTransformer?: EksClusterEntityTransformer;\n }) {\n this.credentialsFactory = options.credentialsFactory;\n this.credentialsManager = options.credentialsManager;\n\n // If the callback function is not passed in, then default to the one upstream is using\n this.clusterEntityTransformer =\n options.clusterEntityTransformer || defaultEksClusterEntityTransformer;\n }\n\n getProcessorName(): string {\n return 'aws-eks';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'aws-eks') {\n return false;\n }\n\n // location target is of format \"account-id/region\"\n const [accountId, region] = location.target.split('/');\n\n if (!accountId || !region) {\n throw new Error(\n 'AWS EKS location specified without account or region information',\n );\n }\n\n let credentials: AwsCredentialIdentity | undefined;\n\n if (this.credentialsFactory) {\n credentials = await this.credentialsFactory(accountId);\n }\n\n let providerFunction: (() => Provider<AwsCredentialIdentity>) | undefined;\n if (this.credentialsManager) {\n const credentialsProvider =\n await this.credentialsManager.getCredentialProvider({ accountId });\n providerFunction = () => credentialsProvider.sdkCredentialProvider;\n }\n\n const eksClient = new EKS({\n credentials,\n credentialDefaultProvider: providerFunction,\n region,\n });\n const clusters = await eksClient.listClusters({});\n if (clusters.clusters === undefined) {\n return true;\n }\n\n const results = clusters.clusters\n .map(cluster => eksClient.describeCluster({ name: cluster }))\n .map(async describedClusterPromise => {\n const describedCluster = await describedClusterPromise;\n if (describedCluster.cluster) {\n const entity = await this.clusterEntityTransformer(\n describedCluster.cluster,\n accountId,\n );\n\n emit({\n type: 'entity',\n entity,\n location,\n });\n }\n });\n await Promise.all(results);\n return true;\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 { 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 processingResult,\n} from '@backstage/plugin-catalog-node';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport {\n Account,\n ListAccountsResponse,\n Organizations,\n} from '@aws-sdk/client-organizations';\nimport { Logger } from 'winston';\nimport { readAwsOrganizationConfig } from '../awsOrganization/config';\nimport {\n AwsCredentialProvider,\n DefaultAwsCredentialsManager,\n} from '@backstage/integration-aws-node';\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 logger: Logger;\n\n static async fromConfig(config: Config, options: { logger: Logger }) {\n const c = config.getOptionalConfig('catalog.processors.awsOrganization');\n const orgConfig = c ? readAwsOrganizationConfig(c) : undefined;\n const awsCredentialsManager =\n DefaultAwsCredentialsManager.fromConfig(config);\n const credProvider = await awsCredentialsManager.getCredentialProvider({\n arn: orgConfig?.roleArn,\n });\n return new AwsOrganizationCloudAccountProcessor(\n credProvider,\n options.logger,\n );\n }\n\n private constructor(\n private readonly credProvider: AwsCredentialProvider,\n logger: Logger,\n ) {\n this.logger = logger?.child({\n target: this.getProcessorName(),\n });\n this.organizations = new Organizations({\n credentialDefaultProvider: () => this.credProvider.sdkCredentialProvider,\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 this.logger?.info('Discovering AWS Organization Account objects');\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(processingResult.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 =\n await this.organizations.listAccounts({ NextToken: nextToken });\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","/*\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 { UrlReader } from '@backstage/backend-common';\nimport { isError } from '@backstage/errors';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n CatalogProcessorParser,\n processingResult,\n} from '@backstage/plugin-catalog-node';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport limiterFactory from 'p-limit';\n\n/**\n * A processor for automatic discovery of entities from S3 buckets. Handles the\n * `s3-discovery` location type, and target bucket URLs e.g. on the form\n * `https://testbucket.s3.us-east-2.amazonaws.com`.\n *\n * @public\n * @deprecated Use the `AwsS3EntityProvider` instead (see https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-aws/CHANGELOG.md#014).\n */\nexport class AwsS3DiscoveryProcessor implements CatalogProcessor {\n constructor(private readonly reader: UrlReader) {}\n\n getProcessorName(): string {\n return 'AwsS3DiscoveryProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n optional: boolean,\n emit: CatalogProcessorEmit,\n parser: CatalogProcessorParser,\n ): Promise<boolean> {\n if (location.type !== 's3-discovery') {\n return false;\n }\n\n try {\n const output = await this.doRead(location.target);\n for (const item of output) {\n for await (const parseResult of parser({\n data: item.data,\n location: { type: location.type, target: item.url },\n })) {\n emit(parseResult);\n }\n }\n } catch (error) {\n const message = `Unable to read ${location.type}, ${error}`;\n\n if (isError(error) && error.name === 'NotFoundError') {\n if (!optional) {\n emit(processingResult.notFoundError(location, message));\n }\n } else {\n emit(processingResult.generalError(location, message));\n }\n }\n return true;\n }\n\n private async doRead(\n location: string,\n ): Promise<{ data: Buffer; url: string }[]> {\n const limiter = limiterFactory(5);\n const response = await this.reader.readTree(location);\n const responseFiles = await response.files();\n const output = responseFiles.map(async file => ({\n url: file.path,\n data: await limiter(file.content),\n }));\n return Promise.all(output);\n }\n}\n"],"names":["ANNOTATION_KUBERNETES_API_SERVER","ANNOTATION_KUBERNETES_API_SERVER_CA","ANNOTATION_KUBERNETES_AUTH_PROVIDER","__publicField","DefaultAwsCredentialsManager","EKS","Organizations","processingResult","isError","limiterFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBO,MAAM,yBAAoC,GAAA,2BAAA;AAM1C,MAAM,kBAA6B,GAAA;;ACC7B,MAAA,kCAAA,GACX,OAAO,OAAA,EAAkB,SAAsB,KAAA;AAC7C,EAAA,MAAM,EAAE,GAAA,EAAK,QAAU,EAAA,oBAAA,EAAsB,MAAS,GAAA,OAAA,CAAA;AACtD,EAAO,OAAA;AAAA,IACL,UAAY,EAAA,uBAAA;AAAA,IACZ,IAAM,EAAA,UAAA;AAAA,IACN,QAAU,EAAA;AAAA,MACR,WAAa,EAAA;AAAA,QACX,CAAC,yBAAyB,GAAG,SAAA;AAAA,QAC7B,CAAC,kBAAkB,GAAG,GAAO,IAAA,EAAA;AAAA,QAC7B,CAACA,uDAAgC,GAAG,QAAY,IAAA,EAAA;AAAA,QAChD,CAACC,0DAAmC,GAClC,CAAA,oBAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,oBAAA,CAAsB,IAAQ,KAAA,EAAA;AAAA,QAChC,CAACC,0DAAmC,GAAG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A;AAC3C,IAAA,MAAM,MAAS,GAAA,aAAA,CAAc,GAAI,CAAA,OAAM,IAAS,MAAA;AAAA,MAC9C,KAAK,IAAK,CAAA,IAAA;AAAA,MACV,IAAM,EAAA,MAAM,OAAQ,CAAA,IAAA,CAAK,OAAO,CAAA;AAAA,KAChC,CAAA,CAAA,CAAA;AACF,IAAO,OAAA,OAAA,CAAQ,IAAI,MAAM,CAAA,CAAA;AAAA,GAC3B;AACF;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { LocationSpec } from '@backstage/plugin-catalog-common';
|
|
|
3
3
|
import { AwsCredentialIdentity } from '@aws-sdk/types';
|
|
4
4
|
import { AwsCredentialsManager } from '@backstage/integration-aws-node';
|
|
5
5
|
import { Config } from '@backstage/config';
|
|
6
|
+
import { Cluster } from '@aws-sdk/client-eks';
|
|
7
|
+
import { Entity } from '@backstage/catalog-model';
|
|
6
8
|
import { Logger } from 'winston';
|
|
7
9
|
import { UrlReader } from '@backstage/backend-common';
|
|
8
10
|
import { TaskRunner, PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
@@ -14,6 +16,13 @@ import { TaskRunner, PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
|
14
16
|
*/
|
|
15
17
|
type AWSCredentialFactory = (awsAccountId: string) => Promise<AwsCredentialIdentity>;
|
|
16
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Options for the EKS cluster entity callback function
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
type EksClusterEntityTransformer = (cluster: Cluster, accountId: string) => Promise<Entity>;
|
|
25
|
+
|
|
17
26
|
/**
|
|
18
27
|
* A processor for automatic discovery of resources from EKS clusters. Handles the
|
|
19
28
|
* `aws-eks` location type, and target accounts/regions of the form
|
|
@@ -24,13 +33,16 @@ type AWSCredentialFactory = (awsAccountId: string) => Promise<AwsCredentialIdent
|
|
|
24
33
|
declare class AwsEKSClusterProcessor implements CatalogProcessor {
|
|
25
34
|
private credentialsFactory?;
|
|
26
35
|
private credentialsManager?;
|
|
27
|
-
|
|
36
|
+
private readonly clusterEntityTransformer;
|
|
37
|
+
static fromConfig(configRoot: Config, options?: {
|
|
38
|
+
clusterEntityTransformer?: EksClusterEntityTransformer;
|
|
39
|
+
}): AwsEKSClusterProcessor;
|
|
28
40
|
constructor(options: {
|
|
29
41
|
credentialsFactory?: AWSCredentialFactory;
|
|
30
42
|
credentialsManager?: AwsCredentialsManager;
|
|
43
|
+
clusterEntityTransformer?: EksClusterEntityTransformer;
|
|
31
44
|
});
|
|
32
45
|
getProcessorName(): string;
|
|
33
|
-
normalizeName(name: string): string;
|
|
34
46
|
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
35
47
|
}
|
|
36
48
|
|
|
@@ -107,4 +119,17 @@ declare class AwsS3EntityProvider implements EntityProvider {
|
|
|
107
119
|
private createObjectUrl;
|
|
108
120
|
}
|
|
109
121
|
|
|
110
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Annotation for specifying AWS account id
|
|
124
|
+
*
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
declare const ANNOTATION_AWS_ACCOUNT_ID: string;
|
|
128
|
+
/**
|
|
129
|
+
* Annotation for specifying AWS arn
|
|
130
|
+
*
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
declare const ANNOTATION_AWS_ARN: string;
|
|
134
|
+
|
|
135
|
+
export { ANNOTATION_AWS_ACCOUNT_ID, ANNOTATION_AWS_ARN, AWSCredentialFactory, AwsEKSClusterProcessor, AwsOrganizationCloudAccountProcessor, AwsS3DiscoveryProcessor, AwsS3EntityProvider, EksClusterEntityTransformer };
|
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.
|
|
4
|
+
"version": "0.3.1-next.0",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -49,17 +49,17 @@
|
|
|
49
49
|
"@aws-sdk/credential-providers": "^3.350.0",
|
|
50
50
|
"@aws-sdk/middleware-endpoint": "^3.347.0",
|
|
51
51
|
"@aws-sdk/types": "^3.347.0",
|
|
52
|
-
"@backstage/backend-common": "^0.19.
|
|
53
|
-
"@backstage/backend-plugin-api": "^0.6.
|
|
54
|
-
"@backstage/backend-tasks": "^0.5.
|
|
55
|
-
"@backstage/catalog-model": "^1.4.3
|
|
56
|
-
"@backstage/config": "^1.1.1
|
|
57
|
-
"@backstage/errors": "^1.2.3
|
|
58
|
-
"@backstage/integration": "^1.7.1
|
|
59
|
-
"@backstage/integration-aws-node": "^0.1.7
|
|
60
|
-
"@backstage/plugin-catalog-common": "^1.0.17
|
|
61
|
-
"@backstage/plugin-catalog-node": "^1.4.
|
|
62
|
-
"@backstage/plugin-kubernetes-common": "^0.7.
|
|
52
|
+
"@backstage/backend-common": "^0.19.9-next.0",
|
|
53
|
+
"@backstage/backend-plugin-api": "^0.6.7-next.0",
|
|
54
|
+
"@backstage/backend-tasks": "^0.5.12-next.0",
|
|
55
|
+
"@backstage/catalog-model": "^1.4.3",
|
|
56
|
+
"@backstage/config": "^1.1.1",
|
|
57
|
+
"@backstage/errors": "^1.2.3",
|
|
58
|
+
"@backstage/integration": "^1.7.1",
|
|
59
|
+
"@backstage/integration-aws-node": "^0.1.7",
|
|
60
|
+
"@backstage/plugin-catalog-common": "^1.0.17",
|
|
61
|
+
"@backstage/plugin-catalog-node": "^1.4.8-next.0",
|
|
62
|
+
"@backstage/plugin-kubernetes-common": "^0.7.1-next.0",
|
|
63
63
|
"@backstage/types": "^1.1.1",
|
|
64
64
|
"lodash": "^4.17.21",
|
|
65
65
|
"p-limit": "^3.0.2",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@aws-sdk/util-stream-node": "^3.350.0",
|
|
71
|
-
"@backstage/backend-test-utils": "^0.2.
|
|
72
|
-
"@backstage/cli": "^0.
|
|
71
|
+
"@backstage/backend-test-utils": "^0.2.8-next.0",
|
|
72
|
+
"@backstage/cli": "^0.24.0-next.0",
|
|
73
73
|
"@types/lodash": "^4.14.151",
|
|
74
74
|
"aws-sdk-client-mock": "^2.0.0",
|
|
75
75
|
"aws-sdk-client-mock-jest": "^2.0.0",
|