@backstage/plugin-catalog-backend-module-aws 0.1.1 → 0.1.3

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,37 @@
1
1
  # @backstage/plugin-catalog-backend-module-aws
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/plugin-catalog-backend@1.0.0
9
+ - @backstage/backend-common@0.13.1
10
+ - @backstage/catalog-model@1.0.0
11
+ - @backstage/config@1.0.0
12
+ - @backstage/errors@1.0.0
13
+ - @backstage/types@1.0.0
14
+
15
+ ## 0.1.2
16
+
17
+ ### Patch Changes
18
+
19
+ - f115a7f8fd: Added `AwsS3DiscoveryProcessor`, which was moved here from `@backstage/plugin-catalog-backend` where it previously resided.
20
+ - Updated dependencies
21
+ - @backstage/backend-common@0.13.0
22
+ - @backstage/plugin-catalog-backend@0.24.0
23
+ - @backstage/catalog-model@0.13.0
24
+
25
+ ## 0.1.2-next.0
26
+
27
+ ### Patch Changes
28
+
29
+ - f115a7f8fd: Added `AwsS3DiscoveryProcessor`, which was moved here from `@backstage/plugin-catalog-backend` where it previously resided.
30
+ - Updated dependencies
31
+ - @backstage/backend-common@0.13.0-next.0
32
+ - @backstage/plugin-catalog-backend@0.24.0-next.0
33
+ - @backstage/catalog-model@0.13.0-next.0
34
+
3
35
  ## 0.1.1
4
36
 
5
37
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -4,10 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var pluginCatalogBackend = require('@backstage/plugin-catalog-backend');
6
6
  var AWS = require('aws-sdk');
7
+ var errors = require('@backstage/errors');
8
+ var limiterFactory = require('p-limit');
7
9
 
8
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
11
 
10
12
  var AWS__default = /*#__PURE__*/_interopDefaultLegacy(AWS);
13
+ var limiterFactory__default = /*#__PURE__*/_interopDefaultLegacy(limiterFactory);
11
14
 
12
15
  function readAwsOrganizationConfig(config) {
13
16
  const providerConfig = config.getOptionalConfig("provider");
@@ -116,5 +119,51 @@ class AwsOrganizationCloudAccountProcessor {
116
119
  }
117
120
  }
118
121
 
122
+ class AwsS3DiscoveryProcessor {
123
+ constructor(reader) {
124
+ this.reader = reader;
125
+ }
126
+ getProcessorName() {
127
+ return "AwsS3DiscoveryProcessor";
128
+ }
129
+ async readLocation(location, optional, emit, parser) {
130
+ if (location.type !== "s3-discovery") {
131
+ return false;
132
+ }
133
+ try {
134
+ const output = await this.doRead(location.target);
135
+ for (const item of output) {
136
+ for await (const parseResult of parser({
137
+ data: item.data,
138
+ location: { type: location.type, target: item.url }
139
+ })) {
140
+ emit(parseResult);
141
+ }
142
+ }
143
+ } catch (error) {
144
+ const message = `Unable to read ${location.type}, ${error}`;
145
+ if (errors.isError(error) && error.name === "NotFoundError") {
146
+ if (!optional) {
147
+ emit(pluginCatalogBackend.processingResult.notFoundError(location, message));
148
+ }
149
+ } else {
150
+ emit(pluginCatalogBackend.processingResult.generalError(location, message));
151
+ }
152
+ }
153
+ return true;
154
+ }
155
+ async doRead(location) {
156
+ const limiter = limiterFactory__default["default"](5);
157
+ const response = await this.reader.readTree(location);
158
+ const responseFiles = await response.files();
159
+ const output = responseFiles.map(async (file) => ({
160
+ url: file.path,
161
+ data: await limiter(file.content)
162
+ }));
163
+ return Promise.all(output);
164
+ }
165
+ }
166
+
119
167
  exports.AwsOrganizationCloudAccountProcessor = AwsOrganizationCloudAccountProcessor;
168
+ exports.AwsS3DiscoveryProcessor = AwsS3DiscoveryProcessor;
120
169
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/awsOrganization/config.ts","../src/processors/AwsOrganizationCloudAccountProcessor.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\n/**\n * The configuration parameters for a single AWS Organization Processor\n */\nexport type AwsOrganizationProviderConfig = {\n /**\n * The role to assume for the processor.\n */\n roleArn?: string;\n};\n\nexport function readAwsOrganizationConfig(\n config: Config,\n): AwsOrganizationProviderConfig {\n const providerConfig = config.getOptionalConfig('provider');\n\n const roleArn = providerConfig?.getOptionalString('roleArn');\n return {\n roleArn,\n };\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { 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"],"names":["AWS","processingResult"],"mappings":";;;;;;;;;;;mCA6BE,QAC+B;AAC/B,QAAM,iBAAiB,OAAO,kBAAkB;AAEhD,QAAM,UAAU,iDAAgB,kBAAkB;AAClD,SAAO;AAAA,IACL;AAAA;AAAA;;ACHJ,MAAM,0BAA0B;AAChC,MAAM,gBAAgB;AAEtB,MAAM,uBAAuB;AAC7B,MAAM,iBAAiB;AACvB,MAAM,0BAA0B;2CAU8C;AAAA,SAIrE,WAAW,QAAgB,SAA6B;AAC7D,UAAM,IAAI,OAAO,kBAAkB;AACnC,WAAO,IAAI,qCAAqC;AAAA,SAC3C;AAAA,MACH,UAAU,IAAI,0BAA0B,KAAK;AAAA;AAAA;AAAA,SAIlC,iBACb,QACyB;AACzB,UAAM,UAAU,OAAO;AACvB,QAA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kBAAY,YAAY;AAAA;AAG1B,WAAO;AAAA;AAAA,EAGD,sBAAsB,SAA0C;AACtE,UAAM,EAAE,WAAW,mBAAmB,KAAK,0BACzC,QAAQ;AAEV,WAAO;AAAA,MACL,YAAY;AAAA,MACZ,MAAM;AAAA,MACN,UAAU;AAAA,QACR,aAAa;AAAA,WACV,uBAAuB;AAAA,WACvB,iBAAiB,QAAQ,OAAO;AAAA,WAChC,0BAA0B;AAAA;AAAA,QAE7B,MAAM,KAAK,cAAc,QAAQ,QAAQ;AAAA,QACzC,WAAW;AAAA;AAAA,MAEb,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,OAAO;AAAA;AAAA;AAAA;AAAA;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/awsOrganization/config.ts","../src/processors/AwsOrganizationCloudAccountProcessor.ts","../src/processors/AwsS3DiscoveryProcessor.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"],"names":["AWS","processingResult","isError","limiterFactory"],"mappings":";;;;;;;;;;;;;;AA4BO,SAAA,yBAAA,CACL,MAC+B,EAAA;AAC/B,EAAM,MAAA,cAAA,GAAiB,OAAO,iBAAkB,CAAA,UAAA,CAAA,CAAA;AAEhD,EAAM,MAAA,OAAA,GAAU,iDAAgB,iBAAkB,CAAA,SAAA,CAAA,CAAA;AAClD,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,GAAA,CAAA;AAAA;;ACHJ,MAAM,uBAA0B,GAAA,WAAA,CAAA;AAChC,MAAM,aAAgB,GAAA,oBAAA,CAAA;AAEtB,MAAM,oBAAuB,GAAA,0BAAA,CAAA;AAC7B,MAAM,cAAiB,GAAA,mBAAA,CAAA;AACvB,MAAM,uBAA0B,GAAA,+BAAA,CAAA;AAU8C,MAAA,oCAAA,CAAA;AAAA,EAIrE,OAAA,UAAA,CAAW,QAAgB,OAA6B,EAAA;AAC7D,IAAM,MAAA,CAAA,GAAI,OAAO,iBAAkB,CAAA,oCAAA,CAAA,CAAA;AACnC,IAAA,OAAO,IAAI,oCAAqC,CAAA;AAAA,MAC3C,GAAA,OAAA;AAAA,MACH,QAAA,EAAU,CAAI,GAAA,yBAAA,CAA0B,CAAK,CAAA,GAAA,EAAA;AAAA,KAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAAA,OAIlC,iBACb,MACyB,EAAA;AACzB,IAAA,MAAM,UAAU,MAAO,CAAA,OAAA,CAAA;AACvB,IAAA,IAAI,CAAC,OAAS,EAAA;AACZ,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,KAAA;AAGT,IAAO,OAAA,IAAIA,wBAAI,6BAA8B,CAAA;AAAA,MAC3C,MAAQ,EAAA;AAAA,QACN,eAAiB,EAAA,sCAAA;AAAA,QACj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backend';
2
+ import { CatalogProcessor, LocationSpec, CatalogProcessorEmit, CatalogProcessorParser } from '@backstage/plugin-catalog-backend';
3
3
  import { Logger } from 'winston';
4
+ import { UrlReader } from '@backstage/backend-common';
4
5
 
5
6
  /**
6
7
  * A processor for ingesting AWS Accounts from AWS Organizations.
@@ -26,4 +27,19 @@ declare class AwsOrganizationCloudAccountProcessor implements CatalogProcessor {
26
27
  private mapAccountToComponent;
27
28
  }
28
29
 
29
- export { AwsOrganizationCloudAccountProcessor };
30
+ /**
31
+ * A processor for automatic discovery of entities from S3 buckets. Handles the
32
+ * `s3-discovery` location type, and target bucket URLs e.g. on the form
33
+ * `https://testbucket.s3.us-east-2.amazonaws.com`.
34
+ *
35
+ * @public
36
+ */
37
+ declare class AwsS3DiscoveryProcessor implements CatalogProcessor {
38
+ private readonly reader;
39
+ constructor(reader: UrlReader);
40
+ getProcessorName(): string;
41
+ readLocation(location: LocationSpec, optional: boolean, emit: CatalogProcessorEmit, parser: CatalogProcessorParser): Promise<boolean>;
42
+ private doRead;
43
+ }
44
+
45
+ export { AwsOrganizationCloudAccountProcessor, AwsS3DiscoveryProcessor };
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.1",
4
+ "version": "0.1.3",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -33,24 +33,27 @@
33
33
  "start": "backstage-cli package start"
34
34
  },
35
35
  "dependencies": {
36
- "@backstage/catalog-model": "^0.12.0",
37
- "@backstage/config": "^0.1.15",
38
- "@backstage/errors": "^0.2.2",
39
- "@backstage/plugin-catalog-backend": "^0.23.0",
40
- "@backstage/types": "^0.1.3",
36
+ "@backstage/backend-common": "^0.13.1",
37
+ "@backstage/catalog-model": "^1.0.0",
38
+ "@backstage/config": "^1.0.0",
39
+ "@backstage/errors": "^1.0.0",
40
+ "@backstage/plugin-catalog-backend": "^1.0.0",
41
+ "@backstage/types": "^1.0.0",
41
42
  "aws-sdk": "^2.840.0",
42
43
  "lodash": "^4.17.21",
44
+ "p-limit": "^3.0.2",
43
45
  "winston": "^3.2.1"
44
46
  },
45
47
  "devDependencies": {
46
- "@backstage/cli": "^0.15.0",
48
+ "@backstage/cli": "^0.16.0",
47
49
  "@types/lodash": "^4.14.151",
48
- "aws-sdk-mock": "^5.2.1"
50
+ "aws-sdk-mock": "^5.2.1",
51
+ "yaml": "^1.9.2"
49
52
  },
50
53
  "files": [
51
54
  "dist",
52
55
  "config.d.ts"
53
56
  ],
54
57
  "configSchema": "config.d.ts",
55
- "gitHead": "04bb0dd824b78f6b57dac62c3015e681f094045c"
58
+ "gitHead": "e9496f746b31600dbfac7fa76987479e66426257"
56
59
  }