Skip to content

Parameters, and How to Add Them

martinlovell edited this page Mar 29, 2022 · 5 revisions

"Adding a parameter", in this case, means "setting an environment variable that ECS hosts can see". This is useful for API keys, hostnames, and other configurations that vary by environment.

In this endeavor, it is important to understand how camerata generates configuration. In order to accommodate the difference between a docker-compose environment (development) and an ECS environment (production), camerata overlays either production, or development configuration files onto a base configuration. For example, for iiif service configuration, the camerata/templates/ directory contains the following files: iiif-images-compose.ecs.yml iiif-images-compose.local.yml iiif-images-compose.yml. In a production configuration, the base config (iiif-images-compose.yml) is overlayed by the ECS configuration: iiif-images-compose.ecs.yml. In development, the .local version is overlayed on the base. Thusly is the final configuration generated.

ECS environment variables are set via the afore-noted configuration files, in the environment section. It should be noted that the values of these variables are often set via local environment variables themselves, which are injected via the .env file, or whatever environment you have set for wherever you happen to be running the deployment (in the production case, this is Jenkins). For example, the AWS_ACCESS_KEY_ID is set to the value ${DEPLOY_KEY_ID}, which is actually a value in the local .env file. This amount of indirection is rage-inducing, but we all know what we signed up for.

Knowing all of this, to add a variable, edit the environment section of the files in camerata/templates/. If you need those variables set in development environments, modify the .local version of the templates. If you need them in production, modify the .ecs version of the templates. If you need it in both, modify the unqualified template. Then you must install camerata via rake install inside the camerata repo, or your changes will not take effect. Note that the Jenkins build system always runs rake install for camerata before deploying.

Having modified the configuration, re-installed camerata, and having deployed, one can verify that the variable has indeed been set by examining the ECS management interface in the AWS console, which displays all the environment variables that have been set for a particular cluster.

Parameter Store Values

  • Variables coming from the parameter store need to be added to the array in cluster.rb.
  • Add the parameter to the parameter store for the correct environments.

Make sure you run rake install in the camerata repository after modifying any templates! Running camaerata commands will use whatever version of camerata you have installed in your gem environment, not whatever you have modified in a local repository.

Here is a checklist:

  • modify the template file
  • if using the parameter store, add parameter store values and add to cluster.rb
  • re-install camerata
  • possibly modify your local environment if using indirect values
  • deploy
  • verify the variable appears in the ECS management console