When using the AWS JavaScript SDK to update an ElasticBeanstalk environment my .ebextensions/*
are being ignored. I'm uploading the application source bundle as a .zip file to S3, which triggers a Lambda to deploy a new application version using this piece of code:
const elasticbeanstalk = new AWS.ElasticBeanstalk();
exports.handler = async (event) => {
const versionLabel = "myVersionString" + (new Date().toUTCString());
// elasticbeanstalk.createApplicationVersion [...]
elasticbeanstalk.updateEnvironment({
"EnvironmentName": "myEBEnvironment",
"VersionLabel": versionLabel
});
};
When uploading the same source bundle within the AWS management console, all my .ebextensions
are being executed as expected.
There is nothing special inside of the *.config files. I'm just creating a few files based on environment variables to use later, e.g.
files:
"/home/ec2-user/prepare_key.sh":
mode: "000777"
content: |
#!/bin/bash
if [ -z ${MY_KEY+x} ]
then
echo "MY_KEY is not set. skip."
else
echo "prepare MY_KEY ..."
echo $MY_KEY > /home/ec2-user/key
fi
container_commands:
set_up:
command: "/home/ec2-user/prepare_key.sh"
As a result the file /home/ec2-user/prepare_key.sh
is not being generated (or updated) and the command set_up
is not being executed during the Lambda deploy.
I double checked the source bundles. All my .ebextensions/*.config
files are there. There are no .ebignore
files in my project directory.
VersionLabel
cannot contain a comma.
In the Lambda I was using new Date().toUTCString()
which is being appended to a static version label. This results in a string like "myVersionString Mon, 09 Sep 2019 08:16:23 GMT"
. The included comma caused .ebextensions
not being properly extracted by Elastic Beanstalk.
I'm now appending just an ISO String, which does not contain any commas.
const versionLabel = "myVersionString" + (new Date().toISOString());