@backstage/plugin-catalog-backend-module-aws 0.1.7-next.1 → 0.1.8-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 CHANGED
@@ -1,5 +1,46 @@
1
1
  # @backstage/plugin-catalog-backend-module-aws
2
2
 
3
+ ## 0.1.8-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 17d45dbf10: Deprecate `AwsS3DiscoveryProcessor` in favor of `AwsS3EntityProvider` (since v0.1.4).
8
+
9
+ You can find a migration guide at
10
+ [the release notes for v0.1.4](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-aws/CHANGELOG.md#014).
11
+
12
+ - Updated dependencies
13
+ - @backstage/backend-common@0.15.0-next.0
14
+ - @backstage/integration@1.3.0-next.0
15
+ - @backstage/backend-tasks@0.3.4-next.0
16
+ - @backstage/plugin-catalog-backend@1.3.1-next.0
17
+
18
+ ## 0.1.7
19
+
20
+ ### Patch Changes
21
+
22
+ - f9f1de8100: Add processor for ingesting EKS clusters into the catalog
23
+ - 72622d9143: Updated dependency `yaml` to `^2.0.0`.
24
+ - Updated dependencies
25
+ - @backstage/plugin-catalog-backend@1.3.0
26
+ - @backstage/backend-common@0.14.1
27
+ - @backstage/catalog-model@1.1.0
28
+ - @backstage/integration@1.2.2
29
+ - @backstage/backend-tasks@0.3.3
30
+ - @backstage/errors@1.1.0
31
+
32
+ ## 0.1.7-next.2
33
+
34
+ ### Patch Changes
35
+
36
+ - 72622d9143: Updated dependency `yaml` to `^2.0.0`.
37
+ - Updated dependencies
38
+ - @backstage/plugin-catalog-backend@1.3.0-next.3
39
+ - @backstage/backend-common@0.14.1-next.3
40
+ - @backstage/integration@1.2.2-next.3
41
+ - @backstage/backend-tasks@0.3.3-next.3
42
+ - @backstage/catalog-model@1.1.0-next.3
43
+
3
44
  ## 0.1.7-next.1
4
45
 
5
46
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var pluginCatalogBackend = require('@backstage/plugin-catalog-backend');
5
+ var catalogModel = require('@backstage/catalog-model');
6
6
  var AWS = require('aws-sdk');
7
+ var pluginCatalogBackend = require('@backstage/plugin-catalog-backend');
7
8
  var errors = require('@backstage/errors');
8
9
  var limiterFactory = require('p-limit');
9
10
  var integration = require('@backstage/integration');
@@ -33,6 +34,72 @@ var AWS__default = /*#__PURE__*/_interopDefaultLegacy(AWS);
33
34
  var limiterFactory__default = /*#__PURE__*/_interopDefaultLegacy(limiterFactory);
34
35
  var uuid__namespace = /*#__PURE__*/_interopNamespace(uuid);
35
36
 
37
+ const ACCOUNTID_ANNOTATION$1 = "amazonaws.com/account-id";
38
+ const ARN_ANNOTATION$1 = "amazonaws.com/arn";
39
+ class AwsEKSClusterProcessor {
40
+ constructor(options) {
41
+ this.credentialsFactory = options.credentialsFactory;
42
+ }
43
+ getProcessorName() {
44
+ return "aws-eks";
45
+ }
46
+ normalizeName(name) {
47
+ return name.trim().toLocaleLowerCase("en-US").replace(/[^a-zA-Z0-9\-]/g, "-");
48
+ }
49
+ async readLocation(location, _optional, emit) {
50
+ if (location.type !== "aws-eks") {
51
+ return false;
52
+ }
53
+ const [accountId, region] = location.target.split("/");
54
+ if (!accountId || !region) {
55
+ throw new Error(
56
+ "AWS EKS location specified without account or region information"
57
+ );
58
+ }
59
+ let credentials;
60
+ if (this.credentialsFactory) {
61
+ credentials = await this.credentialsFactory(accountId);
62
+ }
63
+ const eksClient = new AWS.EKS({ credentials, region });
64
+ const clusters = await eksClient.listClusters({}).promise();
65
+ if (clusters.clusters === void 0) {
66
+ return true;
67
+ }
68
+ const results = clusters.clusters.map((cluster) => eksClient.describeCluster({ name: cluster }).promise()).map(async (describedClusterPromise) => {
69
+ var _a;
70
+ const describedCluster = await describedClusterPromise;
71
+ if (describedCluster.cluster) {
72
+ const entity = {
73
+ apiVersion: "backstage.io/v1alpha1",
74
+ kind: "Resource",
75
+ metadata: {
76
+ annotations: {
77
+ [ACCOUNTID_ANNOTATION$1]: accountId,
78
+ [ARN_ANNOTATION$1]: describedCluster.cluster.arn || "",
79
+ [catalogModel.ANNOTATION_KUBERNETES_API_SERVER]: describedCluster.cluster.endpoint || "",
80
+ [catalogModel.ANNOTATION_KUBERNETES_API_SERVER_CA]: ((_a = describedCluster.cluster.certificateAuthority) == null ? void 0 : _a.data) || "",
81
+ [catalogModel.ANNOTATION_KUBERNETES_AUTH_PROVIDER]: "aws"
82
+ },
83
+ name: this.normalizeName(describedCluster.cluster.name),
84
+ namespace: "default"
85
+ },
86
+ spec: {
87
+ type: "kubernetes-cluster",
88
+ owner: "unknown"
89
+ }
90
+ };
91
+ emit({
92
+ type: "entity",
93
+ entity,
94
+ location
95
+ });
96
+ }
97
+ });
98
+ await Promise.all(results);
99
+ return true;
100
+ }
101
+ }
102
+
36
103
  function readAwsOrganizationConfig(config) {
37
104
  const providerConfig = config.getOptionalConfig("provider");
38
105
  const roleArn = providerConfig == null ? void 0 : providerConfig.getOptionalString("roleArn");
@@ -68,7 +135,9 @@ class AwsOrganizationCloudAccountProcessor {
68
135
  }
69
136
  constructor(options) {
70
137
  this.provider = options.provider;
71
- const credentials = AwsOrganizationCloudAccountProcessor.buildCredentials(this.provider);
138
+ const credentials = AwsOrganizationCloudAccountProcessor.buildCredentials(
139
+ this.provider
140
+ );
72
141
  this.organizations = new AWS__default["default"].Organizations({
73
142
  credentials,
74
143
  region: AWS_ORGANIZATION_REGION
@@ -119,7 +188,9 @@ class AwsOrganizationCloudAccountProcessor {
119
188
  return awsAccounts;
120
189
  }
121
190
  mapAccountToComponent(account) {
122
- const { accountId, organizationId } = this.extractInformationFromArn(account.Arn);
191
+ const { accountId, organizationId } = this.extractInformationFromArn(
192
+ account.Arn
193
+ );
123
194
  return {
124
195
  apiVersion: "backstage.io/v1alpha1",
125
196
  kind: "Resource",
@@ -249,7 +320,10 @@ class AwsS3EntityProvider {
249
320
  });
250
321
  this.s3 = new AWS.S3({
251
322
  apiVersion: "2006-03-01",
252
- credentials: AwsCredentials.create(integration.config, "backstage-aws-s3-provider"),
323
+ credentials: AwsCredentials.create(
324
+ integration.config,
325
+ "backstage-aws-s3-provider"
326
+ ),
253
327
  endpoint: integration.config.endpoint,
254
328
  region: this.config.region,
255
329
  s3ForcePathStyle: integration.config.s3ForcePathStyle
@@ -262,7 +336,14 @@ class AwsS3EntityProvider {
262
336
  if (!integration$1) {
263
337
  throw new Error("No integration found for awsS3");
264
338
  }
265
- return providerConfigs.map((providerConfig) => new AwsS3EntityProvider(providerConfig, integration$1, options.logger, options.schedule));
339
+ return providerConfigs.map(
340
+ (providerConfig) => new AwsS3EntityProvider(
341
+ providerConfig,
342
+ integration$1,
343
+ options.logger,
344
+ options.schedule
345
+ )
346
+ );
266
347
  }
267
348
  createScheduleFn(schedule) {
268
349
  return async () => {
@@ -346,6 +427,7 @@ class AwsS3EntityProvider {
346
427
  }
347
428
  }
348
429
 
430
+ exports.AwsEKSClusterProcessor = AwsEKSClusterProcessor;
349
431
  exports.AwsOrganizationCloudAccountProcessor = AwsOrganizationCloudAccountProcessor;
350
432
  exports.AwsS3DiscoveryProcessor = AwsS3DiscoveryProcessor;
351
433
  exports.AwsS3EntityProvider = AwsS3EntityProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/awsOrganization/config.ts","../src/processors/AwsOrganizationCloudAccountProcessor.ts","../src/processors/AwsS3DiscoveryProcessor.ts","../src/credentials/AwsCredentials.ts","../src/providers/config.ts","../src/providers/AwsS3EntityProvider.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 processingResult,\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(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 = 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","/*\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 LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\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 */\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","/*\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 aws, { Credentials } from 'aws-sdk';\nimport { CredentialsOptions } from 'aws-sdk/lib/credentials';\n\nexport class AwsCredentials {\n /**\n * If accessKeyId and secretAccessKey are missing, the DefaultAWSCredentialsProviderChain will be used:\n * https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html\n */\n static create(\n config: {\n accessKeyId?: string;\n secretAccessKey?: string;\n roleArn?: string;\n },\n roleSessionName: string,\n ): Credentials | CredentialsOptions | undefined {\n if (!config) {\n return undefined;\n }\n\n const accessKeyId = config.accessKeyId;\n const secretAccessKey = config.secretAccessKey;\n let explicitCredentials: Credentials | undefined;\n\n if (accessKeyId && secretAccessKey) {\n explicitCredentials = new Credentials({\n accessKeyId,\n secretAccessKey,\n });\n }\n\n const roleArn = config.roleArn;\n if (roleArn) {\n return new aws.ChainableTemporaryCredentials({\n masterCredentials: explicitCredentials,\n params: {\n RoleArn: roleArn,\n RoleSessionName: roleSessionName,\n },\n });\n }\n\n return explicitCredentials;\n }\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 { Config } from '@backstage/config';\nimport { AwsS3Config } from './types';\n\nconst DEFAULT_PROVIDER_ID = 'default';\n\nexport function readAwsS3Configs(config: Config): AwsS3Config[] {\n const configs: AwsS3Config[] = [];\n\n const providerConfigs = config.getOptionalConfig('catalog.providers.awsS3');\n if (!providerConfigs) {\n return configs;\n }\n\n if (providerConfigs.has('bucketName')) {\n // simple/single config variant\n configs.push(readAwsS3Config(DEFAULT_PROVIDER_ID, providerConfigs));\n\n return configs;\n }\n\n for (const id of providerConfigs.keys()) {\n configs.push(readAwsS3Config(id, providerConfigs.getConfig(id)));\n }\n\n return configs;\n}\n\nfunction readAwsS3Config(id: string, config: Config): AwsS3Config {\n const bucketName = config.getString('bucketName');\n const region = config.getOptionalString('region');\n const prefix = config.getOptionalString('prefix');\n\n return {\n id,\n bucketName,\n region,\n prefix,\n };\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 { TaskRunner } from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { AwsS3Integration, ScmIntegrations } from '@backstage/integration';\nimport {\n EntityProvider,\n EntityProviderConnection,\n LocationSpec,\n locationSpecToLocationEntity,\n} from '@backstage/plugin-catalog-backend';\nimport { AwsCredentials } from '../credentials/AwsCredentials';\nimport { readAwsS3Configs } from './config';\nimport { AwsS3Config } from './types';\nimport { S3 } from 'aws-sdk';\nimport { ListObjectsV2Output } from 'aws-sdk/clients/s3';\nimport * as uuid from 'uuid';\nimport { Logger } from 'winston';\n\n// TODO: event-based updates using S3 events (+ queue like SQS)?\n/**\n * Provider which discovers catalog files (any name) within an S3 bucket.\n *\n * Use `AwsS3EntityProvider.fromConfig(...)` to create instances.\n *\n * @public\n */\nexport class AwsS3EntityProvider implements EntityProvider {\n private readonly logger: Logger;\n private readonly s3: S3;\n private readonly scheduleFn: () => Promise<void>;\n private connection?: EntityProviderConnection;\n\n static fromConfig(\n configRoot: Config,\n options: {\n logger: Logger;\n schedule: TaskRunner;\n },\n ): AwsS3EntityProvider[] {\n const providerConfigs = readAwsS3Configs(configRoot);\n\n // Even though the awsS3 integration allows a config array\n // there is no *real* support for multiple configs.\n // Usually, there will be just the integration for the default host.\n // In case, a custom endpoint is used, the host from this endpoint\n // will be extracted and used as host (e.g., localhost when used with LocalStack)\n // and the default integration will be added as second integration.\n // In this case, we still want the first one though, but have no means to select it\n // just from the bucket name (and region).\n const integration = ScmIntegrations.fromConfig(configRoot).awsS3.list()[0];\n if (!integration) {\n throw new Error('No integration found for awsS3');\n }\n\n return providerConfigs.map(\n providerConfig =>\n new AwsS3EntityProvider(\n providerConfig,\n integration,\n options.logger,\n options.schedule,\n ),\n );\n }\n\n private constructor(\n private readonly config: AwsS3Config,\n integration: AwsS3Integration,\n logger: Logger,\n schedule: TaskRunner,\n ) {\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n\n this.s3 = new S3({\n apiVersion: '2006-03-01',\n credentials: AwsCredentials.create(\n integration.config,\n 'backstage-aws-s3-provider',\n ),\n endpoint: integration.config.endpoint,\n region: this.config.region,\n s3ForcePathStyle: integration.config.s3ForcePathStyle,\n });\n\n this.scheduleFn = this.createScheduleFn(schedule);\n }\n\n private createScheduleFn(schedule: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return schedule.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: AwsS3EntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(error);\n }\n },\n });\n };\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */\n getProviderName(): string {\n return `awsS3-provider:${this.config.id}`;\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n async refresh(logger: Logger) {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n\n logger.info('Discovering AWS S3 objects');\n\n const keys = await this.listAllObjectKeys();\n logger.info(`Discovered ${keys.length} AWS S3 objects`);\n\n const locations = keys.map(key => this.createLocationSpec(key));\n\n await this.connection.applyMutation({\n type: 'full',\n entities: locations.map(location => {\n return {\n locationKey: this.getProviderName(),\n entity: locationSpecToLocationEntity({ location }),\n };\n }),\n });\n\n logger.info(`Committed ${locations.length} Locations for AWS S3 objects`);\n }\n\n private async listAllObjectKeys(): Promise<string[]> {\n const keys: string[] = [];\n\n let continuationToken: string | undefined = undefined;\n let output: ListObjectsV2Output;\n do {\n const request = this.s3.listObjectsV2({\n Bucket: this.config.bucketName,\n ContinuationToken: continuationToken,\n Prefix: this.config.prefix,\n });\n\n output = await request.promise();\n if (output.Contents) {\n output.Contents.forEach(item => {\n if (item.Key && !item.Key.endsWith('/')) {\n keys.push(item.Key);\n }\n });\n }\n continuationToken = output.NextContinuationToken;\n } while (continuationToken);\n\n return keys;\n }\n\n private createLocationSpec(key: string): LocationSpec {\n return {\n type: 'url',\n target: this.createObjectUrl(key),\n presence: 'required',\n };\n }\n\n private createObjectUrl(key: string): string {\n const bucketName = this.config.bucketName;\n const endpoint = this.s3.endpoint.href;\n\n return encodeURI(`${endpoint}${bucketName}/${key}`);\n }\n}\n"],"names":["AWS","processingResult","isError","limiterFactory","Credentials","aws","S3","integration","ScmIntegrations","uuid","locationSpecToLocationEntity"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAAS,yBAAyB,CAAC,MAAM,EAAE;AAClD,EAAE,MAAM,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAC9D,EAAE,MAAM,OAAO,GAAG,cAAc,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAChG,EAAE,OAAO;AACT,IAAI,OAAO;AACX,GAAG,CAAC;AACJ;;ACCA,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAC5C,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAC3C,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AACxD,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,+BAA+B,CAAC;AACzD,MAAM,oCAAoC,CAAC;AAClD,EAAE,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE;AACrC,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC,iBAAiB,CAAC,oCAAoC,CAAC,CAAC;AAC7E,IAAI,OAAO,IAAI,oCAAoC,CAAC;AACpD,MAAM,GAAG,OAAO;AAChB,MAAM,QAAQ,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AAQ,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK;AAC1C,UAAU,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACnD,YAAY,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChC,WAAW;AACX,SAAS,CAAC,CAAC;AACX,OAAO;AACP,MAAM,iBAAiB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,KAAK,QAAQ,iBAAiB,EAAE;AAChC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,kBAAkB,CAAC,GAAG,EAAE;AAC1B,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,KAAK;AACjB,MAAM,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC;AACvC,MAAM,QAAQ,EAAE,UAAU;AAC1B,KAAK,CAAC;AACN,GAAG;AACH,EAAE,eAAe,CAAC,GAAG,EAAE;AACvB,IAAI,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;AAC9C,IAAI,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC3C,IAAI,OAAO,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AACxD,GAAG;AACH;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/processors/AwsEKSClusterProcessor.ts","../src/awsOrganization/config.ts","../src/processors/AwsOrganizationCloudAccountProcessor.ts","../src/processors/AwsS3DiscoveryProcessor.ts","../src/credentials/AwsCredentials.ts","../src/providers/config.ts","../src/providers/AwsS3EntityProvider.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 */\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n} from '@backstage/plugin-catalog-backend';\nimport {\n ANNOTATION_KUBERNETES_API_SERVER,\n ANNOTATION_KUBERNETES_API_SERVER_CA,\n ANNOTATION_KUBERNETES_AUTH_PROVIDER,\n} from '@backstage/catalog-model';\nimport { Credentials, EKS } from 'aws-sdk';\nimport { AWSCredentialFactory } from '../types';\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\n constructor(options: { credentialsFactory?: AWSCredentialFactory }) {\n this.credentialsFactory = options.credentialsFactory;\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: Credentials | undefined;\n\n if (this.credentialsFactory) {\n credentials = await this.credentialsFactory(accountId);\n }\n\n const eksClient = new EKS({ credentials, region });\n const clusters = await eksClient.listClusters({}).promise();\n if (clusters.clusters === undefined) {\n return true;\n }\n\n const results = clusters.clusters\n .map(cluster => eksClient.describeCluster({ name: cluster }).promise())\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 LocationSpec,\n processingResult,\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(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 = 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","/*\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 LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\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","/*\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 aws, { Credentials } from 'aws-sdk';\nimport { CredentialsOptions } from 'aws-sdk/lib/credentials';\n\nexport class AwsCredentials {\n /**\n * If accessKeyId and secretAccessKey are missing, the DefaultAWSCredentialsProviderChain will be used:\n * https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html\n */\n static create(\n config: {\n accessKeyId?: string;\n secretAccessKey?: string;\n roleArn?: string;\n },\n roleSessionName: string,\n ): Credentials | CredentialsOptions | undefined {\n if (!config) {\n return undefined;\n }\n\n const accessKeyId = config.accessKeyId;\n const secretAccessKey = config.secretAccessKey;\n let explicitCredentials: Credentials | undefined;\n\n if (accessKeyId && secretAccessKey) {\n explicitCredentials = new Credentials({\n accessKeyId,\n secretAccessKey,\n });\n }\n\n const roleArn = config.roleArn;\n if (roleArn) {\n return new aws.ChainableTemporaryCredentials({\n masterCredentials: explicitCredentials,\n params: {\n RoleArn: roleArn,\n RoleSessionName: roleSessionName,\n },\n });\n }\n\n return explicitCredentials;\n }\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 { Config } from '@backstage/config';\nimport { AwsS3Config } from './types';\n\nconst DEFAULT_PROVIDER_ID = 'default';\n\nexport function readAwsS3Configs(config: Config): AwsS3Config[] {\n const configs: AwsS3Config[] = [];\n\n const providerConfigs = config.getOptionalConfig('catalog.providers.awsS3');\n if (!providerConfigs) {\n return configs;\n }\n\n if (providerConfigs.has('bucketName')) {\n // simple/single config variant\n configs.push(readAwsS3Config(DEFAULT_PROVIDER_ID, providerConfigs));\n\n return configs;\n }\n\n for (const id of providerConfigs.keys()) {\n configs.push(readAwsS3Config(id, providerConfigs.getConfig(id)));\n }\n\n return configs;\n}\n\nfunction readAwsS3Config(id: string, config: Config): AwsS3Config {\n const bucketName = config.getString('bucketName');\n const region = config.getOptionalString('region');\n const prefix = config.getOptionalString('prefix');\n\n return {\n id,\n bucketName,\n region,\n prefix,\n };\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 { TaskRunner } from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { AwsS3Integration, ScmIntegrations } from '@backstage/integration';\nimport {\n EntityProvider,\n EntityProviderConnection,\n LocationSpec,\n locationSpecToLocationEntity,\n} from '@backstage/plugin-catalog-backend';\nimport { AwsCredentials } from '../credentials/AwsCredentials';\nimport { readAwsS3Configs } from './config';\nimport { AwsS3Config } from './types';\nimport { S3 } from 'aws-sdk';\nimport { ListObjectsV2Output } from 'aws-sdk/clients/s3';\nimport * as uuid from 'uuid';\nimport { Logger } from 'winston';\n\n// TODO: event-based updates using S3 events (+ queue like SQS)?\n/**\n * Provider which discovers catalog files (any name) within an S3 bucket.\n *\n * Use `AwsS3EntityProvider.fromConfig(...)` to create instances.\n *\n * @public\n */\nexport class AwsS3EntityProvider implements EntityProvider {\n private readonly logger: Logger;\n private readonly s3: S3;\n private readonly scheduleFn: () => Promise<void>;\n private connection?: EntityProviderConnection;\n\n static fromConfig(\n configRoot: Config,\n options: {\n logger: Logger;\n schedule: TaskRunner;\n },\n ): AwsS3EntityProvider[] {\n const providerConfigs = readAwsS3Configs(configRoot);\n\n // Even though the awsS3 integration allows a config array\n // there is no *real* support for multiple configs.\n // Usually, there will be just the integration for the default host.\n // In case, a custom endpoint is used, the host from this endpoint\n // will be extracted and used as host (e.g., localhost when used with LocalStack)\n // and the default integration will be added as second integration.\n // In this case, we still want the first one though, but have no means to select it\n // just from the bucket name (and region).\n const integration = ScmIntegrations.fromConfig(configRoot).awsS3.list()[0];\n if (!integration) {\n throw new Error('No integration found for awsS3');\n }\n\n return providerConfigs.map(\n providerConfig =>\n new AwsS3EntityProvider(\n providerConfig,\n integration,\n options.logger,\n options.schedule,\n ),\n );\n }\n\n private constructor(\n private readonly config: AwsS3Config,\n integration: AwsS3Integration,\n logger: Logger,\n schedule: TaskRunner,\n ) {\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n\n this.s3 = new S3({\n apiVersion: '2006-03-01',\n credentials: AwsCredentials.create(\n integration.config,\n 'backstage-aws-s3-provider',\n ),\n endpoint: integration.config.endpoint,\n region: this.config.region,\n s3ForcePathStyle: integration.config.s3ForcePathStyle,\n });\n\n this.scheduleFn = this.createScheduleFn(schedule);\n }\n\n private createScheduleFn(schedule: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return schedule.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: AwsS3EntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(error);\n }\n },\n });\n };\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */\n getProviderName(): string {\n return `awsS3-provider:${this.config.id}`;\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n async refresh(logger: Logger) {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n\n logger.info('Discovering AWS S3 objects');\n\n const keys = await this.listAllObjectKeys();\n logger.info(`Discovered ${keys.length} AWS S3 objects`);\n\n const locations = keys.map(key => this.createLocationSpec(key));\n\n await this.connection.applyMutation({\n type: 'full',\n entities: locations.map(location => {\n return {\n locationKey: this.getProviderName(),\n entity: locationSpecToLocationEntity({ location }),\n };\n }),\n });\n\n logger.info(`Committed ${locations.length} Locations for AWS S3 objects`);\n }\n\n private async listAllObjectKeys(): Promise<string[]> {\n const keys: string[] = [];\n\n let continuationToken: string | undefined = undefined;\n let output: ListObjectsV2Output;\n do {\n const request = this.s3.listObjectsV2({\n Bucket: this.config.bucketName,\n ContinuationToken: continuationToken,\n Prefix: this.config.prefix,\n });\n\n output = await request.promise();\n if (output.Contents) {\n output.Contents.forEach(item => {\n if (item.Key && !item.Key.endsWith('/')) {\n keys.push(item.Key);\n }\n });\n }\n continuationToken = output.NextContinuationToken;\n } while (continuationToken);\n\n return keys;\n }\n\n private createLocationSpec(key: string): LocationSpec {\n return {\n type: 'url',\n target: this.createObjectUrl(key),\n presence: 'required',\n };\n }\n\n private createObjectUrl(key: string): string {\n const bucketName = this.config.bucketName;\n const endpoint = this.s3.endpoint.href;\n\n return encodeURI(`${endpoint}${bucketName}/${key}`);\n }\n}\n"],"names":["ACCOUNTID_ANNOTATION","ARN_ANNOTATION","EKS","ANNOTATION_KUBERNETES_API_SERVER","ANNOTATION_KUBERNETES_API_SERVER_CA","ANNOTATION_KUBERNETES_AUTH_PROVIDER","AWS","processingResult","isError","limiterFactory","Credentials","aws","S3","integration","ScmIntegrations","uuid","locationSpecToLocationEntity"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAMA,sBAAoB,GAAG,0BAA0B,CAAC;AACxD,MAAMC,gBAAc,GAAG,mBAAmB,CAAC;AACpC,MAAM,sBAAsB,CAAC;AACpC,EAAE,WAAW,CAAC,OAAO,EAAE;AACvB,IAAI,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;AACzD,GAAG;AACH,EAAE,gBAAgB,GAAG;AACrB,IAAI,OAAO,SAAS,CAAC;AACrB,GAAG;AACH,EAAE,aAAa,CAAC,IAAI,EAAE;AACtB,IAAI,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;AAClF,GAAG;AACH,EAAE,MAAM,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE;AAChD,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE;AACrC,MAAM,OAAO,KAAK,CAAC;AACnB,KAAK;AACL,IAAI,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC3D,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,EAAE;AAC/B,MAAM,MAAM,IAAI,KAAK;AACrB,QAAQ,kEAAkE;AAC1E,OAAO,CAAC;AACR,KAAK;AACL,IAAI,IAAI,WAAW,CAAC;AACpB,IAAI,IAAI,IAAI,CAA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C,CAAC;AACT,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;AACvC,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE;AAC3B,QAAQ,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK;AAC1C,UAAU,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACnD,YAAY,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChC,WAAW;AACX,SAAS,CAAC,CAAC;AACX,OAAO;AACP,MAAM,iBAAiB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,KAAK,QAAQ,iBAAiB,EAAE;AAChC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,kBAAkB,CAAC,GAAG,EAAE;AAC1B,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,KAAK;AACjB,MAAM,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC;AACvC,MAAM,QAAQ,EAAE,UAAU;AAC1B,KAAK,CAAC;AACN,GAAG;AACH,EAAE,eAAe,CAAC,GAAG,EAAE;AACvB,IAAI,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;AAC9C,IAAI,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC3C,IAAI,OAAO,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AACxD,GAAG;AACH;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,34 @@
1
- import { Config } from '@backstage/config';
2
1
  import { CatalogProcessor, LocationSpec, CatalogProcessorEmit, CatalogProcessorParser, EntityProvider, EntityProviderConnection } from '@backstage/plugin-catalog-backend';
2
+ import { Credentials } from 'aws-sdk';
3
+ import { Config } from '@backstage/config';
3
4
  import { Logger } from 'winston';
4
5
  import { UrlReader } from '@backstage/backend-common';
5
6
  import { TaskRunner } from '@backstage/backend-tasks';
6
7
 
8
+ /**
9
+ * A factory for providing user-specified AWS credentials for a given AWS account.
10
+ *
11
+ * @public
12
+ */
13
+ declare type AWSCredentialFactory = (awsAccountId: string) => Promise<Credentials>;
14
+
15
+ /**
16
+ * A processor for automatic discovery of resources from EKS clusters. Handles the
17
+ * `aws-eks` location type, and target accounts/regions of the form
18
+ * `<accountId>/<region>`.
19
+ *
20
+ * @public
21
+ */
22
+ declare class AwsEKSClusterProcessor implements CatalogProcessor {
23
+ private credentialsFactory?;
24
+ constructor(options: {
25
+ credentialsFactory?: AWSCredentialFactory;
26
+ });
27
+ getProcessorName(): string;
28
+ normalizeName(name: string): string;
29
+ readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
30
+ }
31
+
7
32
  /**
8
33
  * A processor for ingesting AWS Accounts from AWS Organizations.
9
34
  *
@@ -34,6 +59,7 @@ declare class AwsOrganizationCloudAccountProcessor implements CatalogProcessor {
34
59
  * `https://testbucket.s3.us-east-2.amazonaws.com`.
35
60
  *
36
61
  * @public
62
+ * @deprecated Use the `AwsS3EntityProvider` instead (see https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-aws/CHANGELOG.md#014).
37
63
  */
38
64
  declare class AwsS3DiscoveryProcessor implements CatalogProcessor {
39
65
  private readonly reader;
@@ -72,4 +98,4 @@ declare class AwsS3EntityProvider implements EntityProvider {
72
98
  private createObjectUrl;
73
99
  }
74
100
 
75
- export { AwsOrganizationCloudAccountProcessor, AwsS3DiscoveryProcessor, AwsS3EntityProvider };
101
+ export { AWSCredentialFactory, AwsEKSClusterProcessor, AwsOrganizationCloudAccountProcessor, AwsS3DiscoveryProcessor, AwsS3EntityProvider };
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.1.7-next.1",
4
+ "version": "0.1.8-next.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -33,13 +33,13 @@
33
33
  "start": "backstage-cli package start"
34
34
  },
35
35
  "dependencies": {
36
- "@backstage/backend-common": "^0.14.1-next.1",
37
- "@backstage/backend-tasks": "^0.3.3-next.1",
38
- "@backstage/catalog-model": "^1.1.0-next.1",
36
+ "@backstage/backend-common": "^0.15.0-next.0",
37
+ "@backstage/backend-tasks": "^0.3.4-next.0",
38
+ "@backstage/catalog-model": "^1.1.0",
39
39
  "@backstage/config": "^1.0.1",
40
- "@backstage/errors": "^1.1.0-next.0",
41
- "@backstage/integration": "^1.2.2-next.1",
42
- "@backstage/plugin-catalog-backend": "^1.2.1-next.1",
40
+ "@backstage/errors": "^1.1.0",
41
+ "@backstage/integration": "^1.3.0-next.0",
42
+ "@backstage/plugin-catalog-backend": "^1.3.1-next.0",
43
43
  "@backstage/types": "^1.0.0",
44
44
  "aws-sdk": "^2.840.0",
45
45
  "lodash": "^4.17.21",
@@ -48,15 +48,15 @@
48
48
  "winston": "^3.2.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@backstage/cli": "^0.18.0-next.1",
51
+ "@backstage/cli": "^0.18.1-next.0",
52
52
  "@types/lodash": "^4.14.151",
53
53
  "aws-sdk-mock": "^5.2.1",
54
- "yaml": "^1.9.2"
54
+ "yaml": "^2.0.0"
55
55
  },
56
56
  "files": [
57
57
  "dist",
58
58
  "config.d.ts"
59
59
  ],
60
60
  "configSchema": "config.d.ts",
61
- "gitHead": "e0a993834c31487a97a1ae6878eaf3685f03fc1a"
61
+ "gitHead": "fc3229c49caf6eced02ed9516199015bf4682664"
62
62
  }