gpt4 book ai didi

amazon-web-services - 如何使用AWS CDK添加S3 BucketPolicy?

转载 作者:行者123 更新时间:2023-12-03 17:43:38 25 4
gpt4 key购买 nike

我想将这个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com