What is the Difference between Commands and Container_Commands Configuration Keys in Beanstalk?

Introduction

Elastic Beanstalk is one of the PaaS services offered by AWS that provides an easy way to deploy, manage, and run applications. When configuring the environment, two common keys often cause confusion: commands and container_commands. In this blog post, we will unravel the differences between these keys, their specific use cases, and a step-by-step guide to utilizing them effectively.

Concepts Used

Commands

The commands key is used to execute commands on the EC2 instances. These commands run before any of the application and web server processes are set up. The execution order of these commands is determined by the alphanumeric order of their filenames.

Syntax

Container_Commands

container_commands are somewhat similar to commands, but they are executed inside the application source’s staging area, allowing you to modify the deployment package before it’s deployed. They are executed in alphabetical order as well.

Syntax

Step-by-Step Guide: Using Commands and Container_Commands

Step 1: Define Commands

For example, to update the packages on the EC2 instance:

Step 2: Use Container_Commands to Modify Deployment

You might need to make changes to the source code before deployment:

Step 3: Deploy to Beanstalk

Now, with the above-defined configuration, deploy your application to Elastic Beanstalk, observing how the commands and container_commands execute at different stages.

Conclusion

The commands and container_commands keys in Elastic Beanstalk are instrumental in setting up and modifying your environment and application before deployment. While both have their unique uses, the main difference lies in their execution stages, with commands running before the application is set up, and container_commands executing within the application’s staging area. By understanding these distinctions, developers can harness the full potential of Elastic Beanstalk to tailor applications to their specific needs.