This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker-based deployment tooling environment
- Add docker-compose.ci.yml, with a terraform 0.9.11 container for deployments - Add STRATA script to deploy terraform changes and upload files to site bucket - Don’t run STRTA scripts in the VM - Make linter output available outside of app container
- Loading branch information
Showing
8 changed files
with
102 additions
and
54 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,7 @@ deployment/ansible/roles/azavea.* | |
|
||
.env | ||
|
||
deployment/terraform/.terraform | ||
*.tfvars | ||
*.tfplan | ||
*.tfstate* |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: '2.1' | ||
services: | ||
terraform: | ||
image: quay.io/azavea/terraform:0.9.11 | ||
volumes: | ||
- ./:/usr/local/src | ||
- $HOME/.aws:/root/.aws:ro | ||
environment: | ||
- AWS_PROFILE=climate | ||
- CC_DEBUG=1 | ||
- CC_SETTINGS_BUCKET=${CC_SETTINGS_BUCKET:-staging-us-east-1-climate-lab-config} | ||
- CC_SITE_BUCKET=${CC_SITE_BUCKET:-staging-us-east-1-climate-lab-site} | ||
working_dir: /usr/local/src | ||
entrypoint: bash |
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [[ -n "${CC_DEBUG}" ]]; then | ||
set -x | ||
fi | ||
|
||
DIR="$(dirname "$0")" | ||
|
||
TERRAFORM_DIR="${DIR}/../deployment/terraform" | ||
CC_SITE_BUCKET="staging-us-east-1-climate-lab-site" | ||
|
||
function usage() { | ||
echo -n \ | ||
"Usage: $(basename "$0") | ||
Execute Terraform subcommands with remote state management. | ||
" | ||
} | ||
|
||
if [ "${BASH_SOURCE[0]}" = "${0}" ] | ||
then | ||
if [ "${1:-}" = "--help" ] | ||
then | ||
usage | ||
else | ||
if [[ -n "${CC_SETTINGS_BUCKET}" ]] && [[ -n "${CC_SITE_BUCKET}" ]]; | ||
then | ||
pushd "${TERRAFORM_DIR}" | ||
aws s3 cp "s3://${CC_SETTINGS_BUCKET}/terraform/terraform.tfvars" "${CC_SETTINGS_BUCKET}.tfvars" | ||
|
||
case "${1}" in | ||
plan) | ||
rm -rf .terraform terraform.tfstate* | ||
|
||
terraform init \ | ||
-backend-config="bucket=${CC_SETTINGS_BUCKET}" \ | ||
-backend-config="key=terraform/state" | ||
|
||
terraform plan \ | ||
-var-file="${CC_SETTINGS_BUCKET}.tfvars" \ | ||
-out="${CC_SETTINGS_BUCKET}.tfplan" | ||
aws s3 sync --dryrun --delete ../../dist/_site "s3://${CC_SITE_BUCKET}/" | ||
;; | ||
apply) | ||
terraform apply "${CC_SETTINGS_BUCKET}.tfplan" | ||
aws s3 sync --delete ../../dist/_site "s3://${CC_SITE_BUCKET}/" | ||
;; | ||
*) | ||
echo "ERROR: I don't have support for that Terraform subcommand!" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
popd | ||
|
||
else | ||
echo "ERROR: CC_SETTINGS_BUCKET is undefined." | ||
exit 1 | ||
fi | ||
fi | ||
fi |