Elastic Beanstalk saved configurations
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have discussed the command-line interface (EB CLI) in Elastic Beanstalk.
https://cloudaffaire.com/elastic-beanstalk-command-line-interface-eb-cli/
In this blog post, we will discuss saved configurations in Elastic Beanstalk.
Elastic Beanstalk saved configurations:
You can save your existing application environment using Elastic Beanstalk saved configuration option. When you create a saved configuration, Elastic Beanstalk creates a YAML formatted templates that define an environment’s platform version, tier, configuration option settings, and tags. Saved configuration a great way to back up your environment configuration and if required, you can deploy a new environment using saved configuration.
Saved configurations don’t include settings applied with configuration files in your application’s source code. If the same setting is applied in both a configuration file and saved configuration, the setting in the saved configuration takes precedence. Likewise, options specified in the AWS Management Console override options in saved configurations.
Note: Saved configurations are stored in the Elastic Beanstalk S3 bucket in a folder named after your application (s3://elasticbeanstalk-<YOUR-AWS-REGION>-<YOUR-AWS-ACCOUNT>/resources/templates/<YOUR-APPLICATION-NAME>/).
Next, we are going to create a saved configuration of our existing MyShoppingList application. We will use EB CLI to create and manage saved configuration. Alternatively, you can use AWS Elastic Beanstalk console for the same.
Prerequisite for this demo:
- One EC2 AWS Linux 2 instance with proper access.
- One application with a running environment (This is a continuation from the previous demo).
Step 1: Login to the EC2 instance and assume access for EB CLI.
1 2 3 4 5 |
## Login to the EC2 instance ## Assume assess and get inside your application directory cd sh assume_role.sh cd MyShoppingListV2 |
Step 2: Check if any saved configuration exists.
1 2 3 4 5 |
## List existing saved configurations eb config list ## Check if you have any saved configuration in your local directory ls -al .elasticbeanstalk/saved_configs/ |
Note: When you save configuration using EB CLI, its copy the saved configuration form your S3 bucket to .elasticbeanstalk/saved_configs/ location.
Step 3: Create a saved configuration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
## Create a saved configuration for MyShoppingListENV1 environment eb config save --cfg MyShoppingListV2 #Configuration saved at: /home/ec2-user/MyShoppingList/.elasticbeanstalk/saved_configs/MyShoppingListV2.cfg.yml ## Check saved configuration file cat .elasticbeanstalk/saved_configs/MyShoppingListV2.cfg.yml ## List saved configurations eb config list ## Copy your saved configuration from local to S3 ## eb config put MyShoppingListV2 ## Copy your saved configuration from S3 to local ## rm .elasticbeanstalk/saved_configs/MyShoppingListV2.cfg.yml ## eb config get MyShoppingListV2 |
Our saved configuration created successfully.
Next, we are going to create a new environment using our saved configuration.
Step 4: Create a new environment using a saved configuration.
1 2 3 4 5 |
## Terminate the existing environment eb terminate MyShoppingListENV1 --force ## Create a new environment using the saved configuration eb create MyShoppingListENV2 --single --cname MyShoppingList --cfg MyShoppingListV2 |
Cleanup (Do not terminate if you continue with the next blog demo):
1 2 3 4 5 6 7 8 |
## Delete the saved configuration eb config delete MyShoppingListV2 ## Terminate your application eb terminate MyShoppingListENV2 –force --all ## Clear application directory cd .. && rm -rf MyShoppingList Elastic-Beanstalk |
Hope you have enjoyed this article. In the next blog post, we will discuss monitoring in Elastic Beanstalk.
To get a complete list of EB CLI commands, please refer below AWS documentation.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-cmd-commands.html
To get more details on AWS Elastic Beanstalk, please refer below AWS documentation
https://docs.aws.amazon.com/elastic-beanstalk/index.html