Skip to main content

AWS S3 发现

AWS S3 集成有一个特殊的实体提供程序,用于发现位于 S3 桶中的目录实体。 如果你的 S3 桶中包含多个目录文件,并且你想自动发现它们,就可以使用这个提供程序。 该提供程序会抓取你的 S3 桶,并注册与配置路径匹配的实体。 这可以替代静态位置或手动添加目录中的内容。

要使用实体提供程序,您需要 AWS S3 集成设立accessKeyIdsecretAccessKey和/或roleArn或都不是(例如,基于配置文件或实例的凭据)。

在生产部署中,您可能会使用实例附加的权限来管理这些权限。

在配置中,您可以为每个水桶添加一个提供商配置:

# app-config.yaml

catalog:
providers:
awsS3:
yourProviderId: # identifies your dataset / provider independent of config changes
bucketName: sample-bucket
prefix: prefix/ # optional
region: us-east-2 # optional, uses the default region otherwise
schedule: # same options as in TaskScheduleDefinition
# supports cron, ISO duration, "human duration" as used in code
frequency: { minutes: 30 }
# supports ISO duration, "human duration" as used in code
timeout: { minutes: 3 }

对于简单的设置,可以在配置中省略提供程序 ID,其效果与使用default为它。

# app-config.yaml

catalog:
providers:
awsS3:
# uses "default" as provider ID
bucketName: sample-bucket
prefix: prefix/ # optional
region: us-east-2 # optional, uses the default region otherwise
schedule: # same options as in TaskScheduleDefinition
# supports cron, ISO duration, "human duration" as used in code
frequency: { minutes: 30 }
# supports ISO duration, "human duration" as used in code
timeout: { minutes: 3 }

由于该提供程序不属于默认提供程序,因此首先需要安装 AWS 目录插件:

# From your Backstage root directory
yarn add --cwd packages/backend @backstage/plugin-catalog-backend-module-aws

完成后,您还需要将以下段落添加到packages/backend/src/plugins/catalog.ts:

/* packages/backend/src/plugins/catalog.ts */

import { AwsS3EntityProvider } from '@backstage/plugin-catalog-backend-module-aws';

const builder = await CatalogBuilder.create(env);
/** ... other processors and/or providers ... */
builder.addEntityProvider(
AwsS3EntityProvider.fromConfig(env.config, {
logger: env.logger,
scheduler: env.scheduler,
}),
);