5
我想在我的cloudformation脚本中检索一个文件。如果我公开提供该文件,那么它工作正常。如果该文件是私有文件,则cfn脚本将失败,但在/ var/log /中会出现404错误。试图通过wget检索文件导致适当的403错误。如何访问CFN脚本中的受保护的S3文件?
如何从S3检索私人文件?
我的文件条款的样子:
"files" : {
"/etc/httpd/conf/httpd.conf" : {
"source" : "https://s3.amazonaws.com/myConfigBucket/httpd.conf"
}
},
我增加了一个认证条款和相应的参数:
"Parameters" : {
"BucketRole" : {
"Description" : "S3 role for access to bucket",
"Type" : "String",
"Default" : "S3Access",
"ConstraintDescription" : "Must be a valid IAM Role"
}
}
"AWS::CloudFormation::Authentication": {
"default" : {
"type": "s3",
"buckets": [ "myConfigBucket" ],
"roleName": { "Ref" : "BucketRole" }
}
},
我的IAM角色的样子:
{
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": "*"
}
]
}