无法从弹性Beanstalk上传文件到S3,因为访问被拒绝。

huangapple go评论68阅读模式
英文:

Unable to upload file from Elastic Beanstalk to s3 due to access denied

问题

这是我的存储桶策略:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::spmgr/*"
        },
        {
            "Sid": "AllowEBSService",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::823510892997:role/service-role/aws-elasticbeanstalk-service-role"
            },
            "Action": "*",
            "Resource": [
                "arn:aws:s3:::spmgr",
                "arn:aws:s3:::spmgr/*"
            ]
        }
    ]
}

尝试从我的弹性Beanstalk工作实例上传文件时,我收到了拒绝访问的错误。 (请注意,相同的代码在我的本地开发机器上能够成功上传文件)所以我该如何修复它?

英文:

Here is my bucket policy:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::spmgr/*"
        },
        {
            "Sid": "AllowEBSService",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::823510892997:role/service-role/aws-elasticbeanstalk-service-role"
            },
            "Action": "*",
            "Resource": [
                "arn:aws:s3:::spmgr",
                "arn:aws:s3:::spmgr/*"
            ]
        }
    ]
}

On attempting to upload file from my elastic beanstalk worker instance, I get Access denied error.
(Though note that the same code on my local dev machine is able to successfully upload the file)
So how do I fix it?

答案1

得分: 2

aws-elasticbeanstalk-service-role 是为 Elastic Beanstalk 服务本身而设。对于您的应用程序,您必须提供与您的 Elastic Beanstalk 实例配置文件 关联的角色。您需要检查您的 Elastic Beanstalk 实例正在使用哪个角色。

英文:

aws-elasticbeanstalk-service-role is for EB service itself. For your application you have to provide role associated with your Elastic Beanstalk instance profile. You have to check what role your EB instances is
using.

huangapple
  • 本文由 发表于 2023年5月18日 01:32:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76274763.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定