WIP: Make deployment scripts handle multi-environment deployment#140
Open
WIP: Make deployment scripts handle multi-environment deployment#140
Conversation
Sets up the docker-compose config and deployment scripts to take advantage of the new (or impending) docker-compose `--env-file` option. Creating a .env.ENVIRON file then passing the name of the environment to `scripts/deploy` should read that environment file into the project environment. All the variables needed inside the tiler container have to be listed in it's `environment` so they get passed through. Adds a checked-in .env.local file, with credentials for the test database. It doesn't need any of the Lambda or project variables, since it's local.
Changes the deployment-related scripts to expect an argument for which environment to deploy. They'll look for a `.env.ENVIRON` file to set the environment variables and will create claudia-ENVIRON.json and .api-id-ENVIRON files rather than always using the same unqualified names. Using separate claudia.json files means the config file is now given as an argument, rather than using the default, and they go in a subdirectory.
Changes the terraform deployment steps to use local tfplan and tfstate files to keep track of separate environments. The "local" backend is the default, but specifying it explicitly enables specifying parameters for it, i.e. the ENVIRON-based filenames to use. This also switches from using `plan -auto-apply` to doing separate plan and apply commands, though they're still within the same `publish` script. The behavior will end up the same, but it now gives you 10 seconds to bail out if the plan looks weird, rather than applying it as soon as it's calculated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The existing deployment setup relied on single
.env,.api-idandclaudia.jsonfiles, so supporting multiple environments required shuffling different copies around and copying them onto those filenames, which incurs risk of confusion and error.This uses the upcoming
--env-fileoption fordocker-composeto use the same basic.env-based deployment but make it support multiple remote environments.This PR is WIP and not ready for merging because the
--env-fileoption fordocker-composeis in the v1.25 release candidate but not yet in a released version.Also WIP because I need to revise the README to reflect these changes.
Demo
TK
Notes
tfstatefiles by environment. But the storage backend is stilllocal(the default), not S3. Thetfstatefile is important to keep. Without it, Terraform doesn't know how to find the existing CloudFront distribution, so it will make a new one. So if this were going to be used in a situation where multiple people might deploy it, it would need to be switched to S3-backed, or some other way of sharing thetfstatefiles would need to be set up.Testing Instructions
TK
Related to #129 (comment)