2

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?

1 Answer 1

2

The problem was being caused by failing to wait for the new version to be "processed".

The create-application-version command returned:

  [Exec] {
  [Exec]     "ApplicationVersion": {
  [Exec]         "ApplicationName": "MyApp - DEV", 
  [Exec]         "Status": "PROCESSING", 
  [Exec]         "VersionLabel": "0.1.165", 
  [Exec]         "DateCreated": "2016-04-19T19:27:35.948Z", 
  [Exec]         "DateUpdated": "2016-04-19T19:27:35.948Z", 
  [Exec]         "SourceBundle": {
  [Exec]             "S3Bucket": "xxx", 
  [Exec]             "S3Key": "MyApp.0.1.165.zip"
  [Exec]         }
  [Exec]     }
  [Exec] }

I put in a 3 second delay, then ran describe-application-versions, and got

  [Exec]             "Status": "PROCESSED", 

(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 until update-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.

2
  • 1
    wow, good work! thanks for figuring it out, I've been tearing my hair out on this. Jul 23, 2016 at 16:36
  • If you keep getting empty list for your describe-application-versions call, remember to check if caller has elasticbeanstalk:DescribeApplicationVersions privilege ;).
    – xvga
    Jan 23, 2018 at 7:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .