Error occurred during build: Failed to retrieve s3 file

0

Hello team, I have been trying to set up an ssl cerificate, storing its private key and crt in an s3 bucket. The files are currently in the default s3 bucket for elastic beanstalk in the region. The ebs app has an instance role different from the default instance role. I have tried modifying the default value to the instance profile name also tried using the instance role while adding an s3full access permission to it and finally reverting to using the default aws-elasticbeanstalk-ec2-role but all failed with the error - Error occurred during build: Failed to retrieve https://elasticbeanstalk-us-east-2-accountid.s3.us-east-2.amazonaws.com/server.crt. s3 bucket has polict to allow "Action": "s3:PutObject", "s3:ListBucket", "s3:ListBucketVersions", "s3:GetObject", "s3:GetObjectVersion" from both the default beanstalk role and the role I created for the app. Please is there any reason this is failing?

note the accountid used in code is a placeholder

Resources:
  AWSEBAutoScalingGroup:
    Metadata:
      AWS::CloudFormation::Authentication:
        S3Auth:
          type: "s3"
          buckets: ["elasticbeanstalk-us-east-2-accountid"]
          roleName: 
            "Fn::GetOptionSetting": 
              Namespace: "aws:autoscaling:launchconfiguration"
              OptionName: "IamInstanceProfile"
              DefaultValue: "aws-elasticbeanstalk-ec2-role"
files:
  # Private key
  "/etc/pki/tls/certs/server.key":
    mode: "000400"
    owner: root
    group: root
    authentication: "S3Auth"
    source: https://elasticbeanstalk-us-east-2-accountid.s3.us-east-2.amazonaws.com/server.key 
    
files:
  # crt
  "/etc/pki/tls/certs/server.crt":
    mode: "000400"
    owner: root
    group: root
    authentication: "S3Auth"
    source: https://elasticbeanstalk-us-east-2-accountid.s3.us-east-2.amazonaws.com/server.crt 
1 回答
0
已接受的回答

I think it may be due to the incorrect writing of files:. I think it is correct to use files only once, as shown below.

files:
  # Private key
  "/etc/pki/tls/certs/server.key":
    mode: "000400"
    owner: root
    group: root
    authentication: "S3Auth"
    source: https://elasticbeanstalk-us-east-2-accountid.s3.us-east-2.amazonaws.com/server.key 
  # crt
  "/etc/pki/tls/certs/server.crt":
    mode: "000400"
    owner: root
    group: root
    authentication: "S3Auth"
    source: https://elasticbeanstalk-us-east-2-accountid.s3.us-east-2.amazonaws.com/server.crt 

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#linux-files

profile picture
专家
shibata
已回答 1 个月前
  • Thanks for spotting this, it works now.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容