尝试通过控制台设计器创建AWS CloudFormation脚本时,出现上述错误。我确定桶alberto313131存在。
这是完整的错误:
Template contains errors.: Template format error: Unresolved resource dependencies [arn:aws:s3:::alberto313131/*] in the Resources block of the template
这是完整的脚本,我正在使用:
Resources:
S3BP1KK1X:
Type: 'AWS::S3::BucketPolicy'
Properties:
Bucket:
Ref: "arn:aws:s3:::alberto313131/*"
PolicyDocument:
Statement:
- Sid: AddPerm
Effect: Allow
Principal: '*'
Action:
- "s3:GetObject"
Resource:
- "arn:aws:s3:::alberto313131/*"
答案 0 :(得分:2)
从CloudFormation S3 BucketPolicy doco
属性
桶
该策略适用的Amazon S3存储桶的名称。
因此,您只需提供存储桶名称,而不是ARN。
仅对Resource
的{{1}}部分内的Statement
提供ARN。
答案 1 :(得分:0)
我能够使用逻辑ID来解决问题。
Resources:
resbucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: "testathena44"
resbucketpolicy:
Type: "AWS::S3::BucketPolicy"
Properties:
Bucket: !Ref resbucket
PolicyDocument:
Statement:
-
Sid: "ABC123"
Action:
- "s3:GetObject"
Effect: Allow
Resource: !Join ["", ["arn:aws:s3:::", !Ref resbucket, "/*"]]
Principal:
AWS:
- "*"