gpt4 book ai didi

amazon-web-services - AWS CFT 模板 IAM 策略

转载 作者:行者123 更新时间:2023-12-03 07:36:50 25 4
gpt4 key购买 nike

我正在使用 CFT 创建一项 IAM 策略,该策略仅允许单独访问一个 S3 存储桶(该存储桶也是在同一 CFT 本身中创建的)。这是CFT的问题所在的部分

    {
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"BucketCreation":{
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName":"samplebucket",
}
},
"IAMPolicy":{
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": "ListS3BucketsPolicy",
"PolicyDocument": {
"Statement": [{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": "Fn::GetAtt" : [ "BucketCreation" , "Arn" ]
}]
}
}
}
}
}

现在,上面的 cft 使用资源语句创建 IAM 策略 "Resource": "arn:aws:s3:::bucketname" 这仅提供存储桶访问权限,而不提供对象级别访问权限。我需要的是看起来像这样的资源部分 "Resource": "arn:aws:s3:::bucketname/*"。这在 CFT 中可能吗?

最佳答案

是的,可以,请参阅 here

You can use wildcards as part of the resource ARN. You can use wildcard characters (* and ?) within any ARN segment (the parts separated by colons). An asterisk (*) represents any combination of zero or more characters, and a question mark (?) represents any single character. You can use multiple * or ? characters in each segment, but a wildcard cannot span segments.

This ARN uses the wildcard * in the relative-ID part of the ARN to identify all objects in the example bucket.

更新:要连接 /* 请查看 intrinsic functionsJoin

关于amazon-web-services - AWS CFT 模板 IAM 策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52423141/

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