This is an aws-cdk project where you can deploy your Node application on Elastic Beanstalk via Codebuild.
I have created a blog post on understanding how this works here.
Note: This configuration is for GitHub only. For Bitbucket, you can edit the source accordingly.
Prerequisites
- Setup your access and secret keys via the aws-cli and with the profile name of your choice (the default profile is named
default). The credentials generated should have access to creation of all resources mentioned else it won't work.
Steps
- Rename the
.example.envfile to.envand replace all the values with your predefined values for your stack.
Note: All the variables are mandatory! Without that, the stack wouldn't work.
-
Run
npm install -
Run
npm run deploy -- --profile profileNameto deploy the stack to your specified region. You can omit the profile parameter if the profile name isdefault. -
You can start the build from the console in
Codebuildand your Node application works the Beanstalk provided URL!
The cdk.json file tells the CDK Toolkit how to execute your app.
- In the
cdk.jsonthe platform parameter is passed to use the environment for Node 10. You can replace that with any environent of your choice.
You can get the list of platforms using aws elasticbeanstalk list-platform-versions.
npm run buildcompile typescript to jsnpm run deploydeploy this stack to your AWS account/region specified in the.envnpm run watchwatch for changes and compilenpm run testperform the jest unit testscdk diffcompare deployed stack with current statecdk synthemits the synthesized CloudFormation template