通过.ebextensions访问Elastic Beanstalk S3


9

我的文件.ebextensions夹中有一个简单的文件:

00-myconfig.config

Resources:
    AWSEBAutoScalingGroup:
        Metadata:
            AWS::CloudFormation::Authentication:
                S3Access:
                    type: S3
                    roleName: aws-elasticbeanstalk-ec2-role
                    buckets: my-bucket
files:
    "/tmp/ca-bundle.zip":
        mode: "000755"
        owner: root
        group: root
        source: https://s3-ap-southeast-2.amazonaws.com/my-bucket/ca/ca-bundle.zip
        authentication: S3Access

根据多个答案,哪个是授予S3存储桶对该aws-elasticbeanstalk-ec2-role角色访问权限的方法。

但是我继续收到403错误 /var/log/eb-activity.log

[2015-08-26T01:27:03.544Z] INFO  [22320] - [Application update/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild] : Activity execution failed, because: Failed to retrieve https://s3-ap-southeast-2.amazonaws.com/my-bucket/ca/ca-bundle.zip: HTTP Error 403 : <?xml version="1.0" encoding="UTF-8"?> (ElasticBeanstalk::ExternalInvocationError)

如果我手动向aws-elasticbeanstalk-ec2-role角色添加S3访问策略,那么一切正常,因此我知道URL中没有拼写错误或其他错误,那么EC2实例无疑是正确的角色。

怎么了?

PS。我尝试了files具有或不具有“身份验证”设置的部分。

Answers:


9

我已经弄清楚了,因为不及早拿起它而感到有点傻。

因此,对于使用AWS::CloudFormation::Authentication路径的任何人,解决方案当然是:

确保您的BUCKET策略允许您使用aws-elasticbeanstalk-ec2-role。哦!

它看起来应该像这样:

{
    "Id": "Policy1111Blah",
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1440Blah",
            "Action": [
                "s3:GetObject"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::my-bucket/*",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::11111111111:role/aws-elasticbeanstalk-ec2-role"
                ]
            }
        }
    ]
}

您可以从IAM控制台获取ARN。

.ebextensions配置文件中的说明仅告诉EB部署工具使用什么进行身份验证,但是您的源存储桶(如果显然是私有的)需要允许该主体访问!!!

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.