I'm attempting to deploy a .NET application to ElasticBeanstalk using the AWS-cli tools.
First upload then create version using:
aws elasticbeanstalk create-application-version
--application-name "MyApp - DEV"
--version-label "0.1.165"
--source-bundle S3Bucket="xxx",S3Key="MyApp.0.1.165.zip"
--process
This works, so next step:
aws elasticbeanstalk update-environment
--environment-name "myapp-dev-env"
--version-label "0.1.165"
--application-name "MyApp - DEV"
This sometimes exits with code 255 and outputs:
A client error (InvalidParameterValue) occurred when calling the UpdateEnvironment operation: Application version is unusable and cannot be used with an environment
What is frustrating is these exact steps (run by my continuous integration server) sometimes work, and if I go and deploy this version using the AWS console, it also works. The zip I'm uploading doesn't appear any different, and in fact, if I rebuild from the same source revision (using a build that previously deployed successfully, which gives it a new version number), it seems to (usually) run into this problem.
I can't find any detail about what this error means, so where else can I look to figure out what's happening?
The problem was being caused by failing to wait for the new version to be "processed".
The
create-application-version
command returned:I put in a 3 second delay, then ran
describe-application-versions
, and got(interestingly, the
DateUpdated
did not change)After that, the
update-environment
command works fine, and I've deployed several versions without issue.A proper fix would be to keep running
describe-application-versions
until Status!="Processing", and then handle all the failure cases (status other than "Processing" or "Processed", or staying as "Processing" forever).In my case, I'm invoking this from msbuild (where looping and waiting is very difficult), so I'm happy enough with the workaround of an arbitrary delay, and allowing the
update-environment
command to fail if something goes wrong. Because production remains untouched untilupdate-environment
, and actual time taken to deploy (leading up to that command) is not important, I just don't need to go through that much effort.