I have an elastic beanstalk Node app that I'm trying to setup. I'm trying to load an environment file from S3 into /var/app/ondeck/src/ so the file is available when the Node app is started. I've tried as many things as I can think of but the production.env file never shows up. If I change the location to something like /home/ec2-user the file appears so I know that I have the file part correct. What am I missing?
files:
"/var/app/ondeck/src/production.env":
mode: "000777"
user: nodejs
group: nodejs
source: https://s3.amazonaws.com/bucket-name/file.env
Resources:
AWSEBAutoScalingGroup:
Metadata:
AWS::CloudFormation::Authentication:
S3Access:
type: S3
roleName: aws-elasticbeanstalk-ec2-role
buckets: bucket-name
========
A last resort idea was to run a container_command that would just copy the file from /home/ec2-user into /var/app/current/src/ or /var/app/ondeck/src/ but that didn't seem to work either. I prefer to get the top example to work if at all possible.
container_commands:
command: "/bin/cp /home/ec2-user/production.env /var/app/ondeck/production.env"
Your latter option seems to be working for me with some modifications. Note the following:
mv instead of cpwebapp instead of nodejs, but probably that's just because of me using Beanstalk for PHP rather than NodeIt'd be something like:
files:
"/home/ec2-user/production.env":
mode: "000644"
owner: nodejs
group: nodejs
source: https://s3.amazonaws.com/bucket-name/file.env
container_commands:
01_mv_to_app_dir:
command: "mv /home/ec2-user/production.env ./production.env"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With