initial commit of replacement infrastructure automation
[awsible] / infrastructure / generate-backend-configs.sh
1 #!/bin/bash
2 # this is a rough hack at the moment, it needs to be better
3
4 set -e
5 set -o pipefail
6
7 tf_infra=$(pushd ../terraform-infrastructure >/dev/null && terraform output -json && popd >/dev/null)
8 function infra_value(){
9 jq -er ".${1}.value"<<<"${tf_infra}"
10 }
11
12 cat<<EOF
13 terraform {
14 backend "s3" {
15 region = "$(infra_value region)"
16 bucket = "$(infra_value remote_state_bucket)"
17 dynamodb_table = "$(infra_value remote_state_table)"
18 key = "$(infra_value environment)/$(basename $(pwd)).tfstate"
19 }
20 }
21 EOF