gpt4 book ai didi

amazon-web-services - AWS BucketPolicy 无法创建 - 策略语法无效 MalformedPolicy

转载 作者:行者123 更新时间:2023-12-03 07:14:19 24 4
gpt4 key购买 nike

我尝试在 yaml 中创建以下存储桶策略,但存储桶策略无法创建:

Cloudformation 错误消息:

Invalid policy syntax. (Service: Amazon S3; Status Code: 400; Error Code: MalformedPolicy; Request ID: CD4; S3 Extended Request ID: Noxxxx/sXX=; Proxy: null)

需要完成的存储桶策略:

{
"Version": "2012-10-17",
"Id": "ig",
"Statement": [
{
"Sid": "LZone",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123:role/l-zone"
},
"Action": [
"s3:AbortMultipartUpload",
"s3:ListBucket",
"s3:PutObject",
"s3:GetObject",
"s3:GetObjectVersion",
"s3:PutObjectAcl"
],
"Resource": [
"arn:aws:s3:::bucketname-l/*",
"arn:aws:s3:::bucketname-l"
]
}
]
}

这是上述策略的 yaml 代码(不起作用):

LBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub bucketname-l
LBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref LBucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: LZone
Effect: Allow
Action:
- 's3:AbortMultipartUpload'
- 's3:ListBucket'
- 's3:PutObject'
- 's3:GetObject'
- 's3:GetObjectVersion'
- 's3:PutObjectAcl'
Resource:
Fn::Join:
- ""
-
- "arn:aws:s3:::"
-
Ref: "LBucket"
- "/*"
Principal: "AWS: arn:aws:iam::123:role/l-zone"

有人可以帮我解决我所缺少的事情吗?谢谢

最佳答案

政策应该是:

  LBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref LBucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: LZone
Effect: Allow
Action:
- 's3:AbortMultipartUpload'
- 's3:ListBucket'
- 's3:PutObject'
- 's3:GetObject'
- 's3:GetObjectVersion'
- 's3:PutObjectAcl'
Resource:
- !Sub "arn:aws:s3:::${LBucket}"
- !Sub "arn:aws:s3:::${LBucket}/*"
Principal:
AWS: arn:aws:iam::123:role/l-zone

关于amazon-web-services - AWS BucketPolicy 无法创建 - 策略语法无效 MalformedPolicy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63837437/

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