Change an application environment variable
Background
-
Applications run as containers on an AWS ECS cluster
-
Environment variables are detailed within the ECS Task Definition for an application
-
Task Definitions are provisioned via the application module of the infrastructure code repository
-
The application module receives environment variables as a parameter of type: map
Steps
To change an application’s environment variables:
- Navigate to the correct system folder within the infrastructure code repository, e.g. the main application is found within the platform system
- Locate the module for the application in question, e.g.
module "application_main" {...}
- One of the module parameters is named
environment
and should contain a map of environment keys to values. - To add a new variable, simply append a new key value pair to the map.
- You can also change existing values in the map
- It’s also possible to remove a key value pair which is no longer needed. Consider what impact this might have on the application.
- Run a Terraform plan in the usual way to review that your changes are as expected
- Finally, run a Terrraform apply if you are happy to proceed
[!TIP]
Always try to make changes in a backwards (and forwards) compatible manner