我想将这个 CloudFormation 片段翻译成 CDK:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: S3BucketImageUploadBuffer
PolicyDocument:
Version: "2012-10-17"
Statement:
Action:
- s3:PutObject
- s3:PutObjectAcl
Effect: Allow
Resource:
- ...
查看documentation here ,我没有找到提供政策文件本身的方法。
最佳答案
这是来自工作 CDK 堆栈的示例:
artifactBucket.addToResourcePolicy(
new PolicyStatement({
resources: [
this.pipeline.artifactBucket.arnForObjects("*"),
this.pipeline.artifactBucket.bucketArn],
],
actions: ["s3:List*", "s3:Get*"],
principals: [new ArnPrincipal(this.deploymentRole.roleArn)]
})
);
关于amazon-web-services - 如何使用AWS CDK添加S3 BucketPolicy?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60310575/