我有一个AWS Elastic Beanstalk Rails应用程序,正在通过配置脚本进行配置,以从S3存储桶中提取一些文件。启动应用程序时,我在日志中始终收到以下错误(出于安全性考虑,存储桶名称已更改):
Failed to retrieve https://s3.amazonaws.com/my.bucket/bootstrap.sh: HTTP Error 403 : <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message>
配置文件:
packages:
yum:
git: []
files:
/opt/elasticbeanstalk/hooks/appdeploy/pre/01a_bootstrap.sh:
mode: "00755"
owner: root
group: root
source: https://s3.amazonaws.com/my.bucket/bootstrap.sh
设置了具有aws-elasticbeanstalk-ec2-role
IAM角色作为实例角色的Elastic Beanstalk环境。该角色具有以下策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": "arn:aws:s3:::my.bucket/*"
}
]
}
S3存储桶具有以下策略:
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "Stmt1371012493903",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<account #>:role/aws-elasticbeanstalk-ec2-role"
},
"Action": [
"s3:List*",
"s3:Get*"
],
"Resource": "arn:aws:s3:::my.bucket/*"
}
]
}
我需要更改什么以使EC2实例能够访问我的S3存储桶?