Search code examples
amazon-web-servicesamazon-elastic-beanstalkaws-cdk

Configuration files cannot be extracted from the application version - CDK deployed ElasticBeanstalk app with .ebextensions


I have a PHP app I'm trying to deploy to Beanstalk with a CDK pipeline.
I use aws-s3-assets/Asset to bundle the app into a zip file, then pass the BucketName and ObjectKey as a sourceBundle parameter to aws-elasticbeanstalk/CfnApplicationVersion

When all Pipeline steps go through and the EB Environment update starts doing its thing, it pops up with this Warming:

Configuration files cannot be extracted from the application version test-beanstalk-phpapiversion-h1nvscneb6gl-1. Check that the application version is a valid zip or war file.

Then continues successfully, but the .ebextensions config files look like they have not ran on the instance (logs are clean of any config outputs)

Where it gets confusing is:

  • When I upload a zip of the same folder, but created locally with 7zip (still as a .zip file). It all goes through fine, no Warning and the .ebextension configs run okay on the instance. The file structure in the zip file is exactly the same.
  • When I create a zip where the contents are app/* (when extracted the content files of app are in the app folder) the .ebextension configs run, but the composer config is not found. Returning:

You didn't include a 'composer.json' file in your source bundle. The deployment didn't install Composer dependencies.


My folder structure is:

root
 |_ infra (cdk app)
    app (php app)
     |_ .ebextensions
    others_files
        composer.json

The directory path I give aws-s3-assets/Asset is:

path: ${__dirname}/../../app


Solution

  • Still don't know what the cause of the strange behaviour is, that may be up to AWS/CDK team to confirm. But the cleanest most reasonable supported solution was to ignore .ebextension config files and use platform hooks instead.

    Details on Extending Elastic Beanstalk Linux platforms

    Will update with more details after I have migrated all traditional config files into the platform expected format and sequence.