在documentation Use an Existing AWS CloudFormation Template中有一节。它使用来自文件系统(fs.readFileSync)的同步功能。我使用的是S3 EKS Public and private subnets的CloudFormation模板。根据我的理解,AWS CDK是同步的,我不能使用请求库来获取现有的模板。可以选择将yaml文件下载到本地文件系统。
我想直接从S3使用模板,如果可能的话。
发布于 2019-09-30 06:38:09
当然,只要使用aws-sdk从它所在的存储桶中获取s3内容即可。
async getCfnIncludeFromS3(): Promise<cdk.CfnInclude> {
const s3 = new aws.S3();
const template = await s3.getObject({Bucket: "MyBucket", Key: "My/Key/To/Template.json"}).promise();
return new cdk.CfnInclude(this, "ExistingInfrastructure", {
template: JSON.parse(template.Body).toString()
});
}https://stackoverflow.com/questions/58135261
复制相似问题