Reputation: 686
I'm attempting to copy a file from an S3 bucket to an NodeJS app on Beanstalk when I deploy a new version.
What I've done so far:
Resources: AWSEBAutoScalingGroup: Metadata: AWS::CloudFormation::Authentication: S3Auth: type: "s3" buckets: ["bucket-name"] roleName: aws-elasticbeanstalk-ec2-role files: "/tmp/deployment/application/file_needed.json" : mode: "000644" owner: root group: root authentication: "S3Auth" source: https://[bucket-name].s3.[region].amazonaws.com/origin_file.json
The app deploys with no errors, but the file, file_needed.json, does not get copied?
Update: After trying a different folder destination (/tmp), I've found that files are copied. What I know is that Beanstalk first extracts the files to /tmp/deployment/application/, and then moves them to /var/app/current. How can I get the files to copy to the root directory of the app?
Upvotes: 1
Views: 1372
Reputation: 510
I followed this Download S3 and Add to App Directory
I used the default bucket created by EB and added a new role with permissions to read from S3
Also to copy the files you should use container_commands https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#linux-container-commands
Whatever files you want to copy need to be added to the staging folder, this is mentioned in the above link
this is what I used to copy the file to my deployed code
command: "mv /home/ec2-user/.env.production /var/app/staging/.env.production"
Also if you want your file to readable change the owner and group to webapp
this command shows you all available users less /etc/passwd
To find your apps user group you can also just check the permission of the files in app/current
Upvotes: 0
Reputation: 51654
The reason might be a case-sensitivity issue. In AWS::CloudFormation::Authentication the type is set to "s3" instead of "S3".
Also try removing “region” from the bucket URL:
source: https://bucket-name.s3.amazonaws.com/origin_file.json
Upvotes: 0