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 Risposta
0
Risposta accettata

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
ESPERTO
shibata
con risposta un mese fa
  • Thanks for spotting this, it works now.

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande