Repository: chanzuckerberg/fogg
Pull request #463 (2020-04-20 19:55:40)

[fix] set TF_BACKEND_KIND in environment comonents
We were correctly setting this for global and acconts, but not
environment components. Our Makefiles need to know the kind of backend
so that they can set proper flags on our variables invocations of the
terraform command.

### Summary
A description of changes or issues addressed by this PR. Provide links to relevant PRs if any.

### Test Plan
Say unittests, or list out steps to verify changes.

### References
(Optional) Additional links to provide more context.


Patch:
diff --git a/go.sum b/go.sum
index e7bc6e9d..7f692ccd 100644
--- a/go.sum
+++ b/go.sum
@@ -98,8 +98,6 @@ github.com/aws/aws-lambda-go v1.12.1/go.mod h1:z4ywteZ5WwbIEzG0tXizIAUlUwkTNNknX
 github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM=
 github.com/aws/aws-sdk-go v1.23.2/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
 github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
-github.com/aws/aws-sdk-go v1.25.48 h1:J82DYDGZHOKHdhx6hD24Tm30c2C3GchYGfN0mf9iKUk=
-github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
 github.com/aws/aws-sdk-go v1.30.7 h1:IaXfqtioP6p9SFAnNfsqdNczbR5UNbYqvcZUSsCAdTY=
 github.com/aws/aws-sdk-go v1.30.7/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
 github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc=
@@ -268,10 +266,6 @@ github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6K
 github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
 github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
 github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
-github.com/hashicorp/go-getter v1.4.0 h1:ENHNi8494porjD0ZhIrjlAHnveSFhY7hvOJrV/fsKkw=
-github.com/hashicorp/go-getter v1.4.0/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY=
-github.com/hashicorp/go-getter v1.4.1 h1:3A2Mh8smGFcf5M+gmcv898mZdrxpseik45IpcyISLsA=
-github.com/hashicorp/go-getter v1.4.1/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY=
 github.com/hashicorp/go-getter v1.4.2-0.20200106182914-9813cbd4eb02 h1:l1KB3bHVdvegcIf5upQ5mjcHjs2qsWnKh4Yr9xgIuu8=
 github.com/hashicorp/go-getter v1.4.2-0.20200106182914-9813cbd4eb02/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY=
 github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI=
@@ -309,30 +303,19 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
 github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
 github.com/hashicorp/hcl/v2 v2.0.0 h1:efQznTz+ydmQXq3BOnRa3AXzvCeTq1P4dKj/z5GLlY8=
 github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90=
-github.com/hashicorp/hcl/v2 v2.1.0 h1:GNoCF4TJPJ/ZNAAOylHmSc/gECnMStnGacR9j3hIQw8=
-github.com/hashicorp/hcl/v2 v2.1.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90=
 github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggUE=
 github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8=
-github.com/hashicorp/hcl2 v0.0.0-20190821123243-0c888d1241f6/go.mod h1:Cxv+IJLuBiEhQ7pBYGEuORa0nr4U994pE8mYLuFd7v0=
 github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80 h1:PFfGModn55JA0oBsvFghhj0v93me+Ctr3uHC/UmFAls=
 github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80/go.mod h1:Cxv+IJLuBiEhQ7pBYGEuORa0nr4U994pE8mYLuFd7v0=
 github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590 h1:2yzhWGdgQUWZUCNK+AoO35V+HTsgEmcM4J9IkArh7PI=
 github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590/go.mod h1:n2TSygSNwsLJ76m8qFXTSc7beTb+auJxYdqrnoqwZWE=
 github.com/hashicorp/hil v0.0.0-20190212132231-97b3a9cdfa93 h1:T1Q6ag9tCwun16AW+XK3tAql24P4uTGUMIn1/92WsQQ=
 github.com/hashicorp/hil v0.0.0-20190212132231-97b3a9cdfa93/go.mod h1:n2TSygSNwsLJ76m8qFXTSc7beTb+auJxYdqrnoqwZWE=
-github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
-github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
 github.com/hashicorp/memberlist v0.1.0/go.mod h1:ncdBp14cuox2iFOq3kDiquKU6fqsTBc3W6JvZwjxxsE=
 github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb h1:ZbgmOQt8DOg796figP87/EFCVx2v2h9yRvwHF/zceX4=
 github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE=
-github.com/hashicorp/terraform v0.12.17 h1:U4gOJWeG1/ICNS4CHSTjFsM7hxOM1t+2GDTq2TDiCLg=
-github.com/hashicorp/terraform v0.12.17/go.mod h1:LQR1l9+qbkA0ZKujo+7dk3tSKhYmG5LQjogPW6DZblI=
 github.com/hashicorp/terraform v0.12.24 h1:lTTswsCcmTOhTwuUl2NdjtJBCNdGqZmRGQi0cjFHYOM=
 github.com/hashicorp/terraform v0.12.24/go.mod h1:eJcloDEx5ywM4a1tetIuVrlqklM0bUVRYJBYAh4CYzA=
-github.com/hashicorp/terraform-config-inspect v0.0.0-20190821133035-82a99dc22ef4 h1:fTkL0YwjohGyN7AqsDhz6bwcGBpT+xBqi3Qhpw58Juw=
-github.com/hashicorp/terraform-config-inspect v0.0.0-20190821133035-82a99dc22ef4/go.mod h1:JDmizlhaP5P0rYTTZB0reDMefAiJyfWPEtugV4in1oI=
-github.com/hashicorp/terraform-config-inspect v0.0.0-20191121111010-e9629612a215 h1:H50GDgzwwTZzPkX8eTvkkkEbMRhUyMl8YUcT7nkeIhk=
-github.com/hashicorp/terraform-config-inspect v0.0.0-20191121111010-e9629612a215/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A=
 github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7 h1:Pc5TCv9mbxFN6UVX0LH6CpQrdTM5YjbVI2w15237Pjk=
 github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A=
 github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 h1:hjyO2JsNZUKT1ym+FAdlBEkGPevazYsmVgIMw7dVELg=
@@ -414,7 +397,6 @@ github.com/lusis/go-artifactory v0.0.0-20160115162124-7e4ce345df82/go.mod h1:y54
 github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5/go.mod h1:c2mYKRyMb1BPkO5St0c/ps62L4S0W2NAkaTXj9qEI+0=
 github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018/go.mod h1:sFlOUpQL1YcjhFVXhg1CG8ZASEs/Mf1oVb6H75JL/zg=
 github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
-github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
 github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9 h1:SmVbOZFWAlyQshuMfOkiAx1f5oUTsOGG5IXplAEYeeM=
 github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc=
 github.com/masterzen/winrm v0.0.0-20190223112901-5e5c9a7fe54b h1:/1RFh2SLCJ+tEnT73+Fh5R2AO89sQqs8ba7o+hx1G0Y=
@@ -602,8 +584,6 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:
 github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
 github.com/zclconf/go-cty v1.1.0 h1:uJwc9HiBOCpoKIObTQaLR+tsEXx1HBHnOsOOpcdhZgw=
 github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
-github.com/zclconf/go-cty v1.1.1 h1:Shl2p9Dat0cqJfXu0DZa+cOTRPhXQjK8IYWD6GVfiqo=
-github.com/zclconf/go-cty v1.1.1/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
 github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
 github.com/zclconf/go-cty v1.2.1 h1:vGMsygfmeCl4Xb6OA5U5XVAaQZ69FvoG7X2jUtQujb8=
 github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
diff --git a/templates/component/terraform/Makefile.tmpl b/templates/component/terraform/Makefile.tmpl
index c32af392..133418ec 100644
--- a/templates/component/terraform/Makefile.tmpl
+++ b/templates/component/terraform/Makefile.tmpl
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := {{ .TerraformVersion }}
 export TFLINT_ENABLED := {{ if .TfLint.Enabled }}1{{ else }}0{{ end }}
 export TF_PLUGIN_CACHE_DIR := {{ .PathToRepoRoot }}/.terraform.d/plugin-cache
+export TF_BACKEND_KIND := {{ .Backend.Kind }}
 {{ if eq .Backend.Kind "s3" }}export AWS_BACKEND_PROFILE := {{ .Backend.S3.Profile }}{{ end }}
 {{if .Providers.AWS}}
 export AWS_PROVIDER_PROFILE := {{ .Providers.AWS.Profile }}


Test patch:
diff --git a/testdata/bless_provider_yaml/terraform/envs/bar/bam/Makefile b/testdata/bless_provider_yaml/terraform/envs/bar/bam/Makefile
index 78ef2324..c0665191 100644
--- a/testdata/bless_provider_yaml/terraform/envs/bar/bam/Makefile
+++ b/testdata/bless_provider_yaml/terraform/envs/bar/bam/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 1.1.1
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := foofoo
 
 
diff --git a/testdata/component_kind/terraform/envs/env1/foo/Makefile b/testdata/component_kind/terraform/envs/env1/foo/Makefile
index bd4de971..034378c4 100644
--- a/testdata/component_kind/terraform/envs/env1/foo/Makefile
+++ b/testdata/component_kind/terraform/envs/env1/foo/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 1.1.1
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := remote
 
 
 
diff --git a/testdata/github_provider_yaml/terraform/envs/bar/bam/Makefile b/testdata/github_provider_yaml/terraform/envs/bar/bam/Makefile
index 96821f89..40ff49de 100644
--- a/testdata/github_provider_yaml/terraform/envs/bar/bam/Makefile
+++ b/testdata/github_provider_yaml/terraform/envs/bar/bam/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 1.1.1
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := foo
 
 
diff --git a/testdata/okta_provider_yaml/terraform/envs/bar/bam/Makefile b/testdata/okta_provider_yaml/terraform/envs/bar/bam/Makefile
index 78ef2324..c0665191 100644
--- a/testdata/okta_provider_yaml/terraform/envs/bar/bam/Makefile
+++ b/testdata/okta_provider_yaml/terraform/envs/bar/bam/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 1.1.1
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := foofoo
 
 
diff --git a/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/Makefile b/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/Makefile
index 96821f89..40ff49de 100644
--- a/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/Makefile
+++ b/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 1.1.1
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := foo
 
 
diff --git a/testdata/tfe_provider_yaml/terraform/envs/bar/bam/Makefile b/testdata/tfe_provider_yaml/terraform/envs/bar/bam/Makefile
index 96821f89..40ff49de 100644
--- a/testdata/tfe_provider_yaml/terraform/envs/bar/bam/Makefile
+++ b/testdata/tfe_provider_yaml/terraform/envs/bar/bam/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 1.1.1
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := foo
 
 
diff --git a/testdata/v2_full_yaml/terraform/envs/prod/datadog/Makefile b/testdata/v2_full_yaml/terraform/envs/prod/datadog/Makefile
index 2b3d78bb..4a8d1eee 100644
--- a/testdata/v2_full_yaml/terraform/envs/prod/datadog/Makefile
+++ b/testdata/v2_full_yaml/terraform/envs/prod/datadog/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 0.100.0
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := profile
 
 export AWS_PROVIDER_PROFILE := profile
diff --git a/testdata/v2_full_yaml/terraform/envs/prod/hero/Makefile b/testdata/v2_full_yaml/terraform/envs/prod/hero/Makefile
index 3c9e1b1f..77bb069b 100644
--- a/testdata/v2_full_yaml/terraform/envs/prod/hero/Makefile
+++ b/testdata/v2_full_yaml/terraform/envs/prod/hero/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 0.100.0
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := profile
 
 export AWS_PROVIDER_PROFILE := profile
diff --git a/testdata/v2_full_yaml/terraform/envs/staging/comp1/Makefile b/testdata/v2_full_yaml/terraform/envs/staging/comp1/Makefile
index e27c3730..fcc94951 100644
--- a/testdata/v2_full_yaml/terraform/envs/staging/comp1/Makefile
+++ b/testdata/v2_full_yaml/terraform/envs/staging/comp1/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 0.100.0
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := comp1
 
 export AWS_PROVIDER_PROFILE := profile
diff --git a/testdata/v2_full_yaml/terraform/envs/staging/comp2/Makefile b/testdata/v2_full_yaml/terraform/envs/staging/comp2/Makefile
index 2b3d78bb..4a8d1eee 100644
--- a/testdata/v2_full_yaml/terraform/envs/staging/comp2/Makefile
+++ b/testdata/v2_full_yaml/terraform/envs/staging/comp2/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 0.100.0
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := profile
 
 export AWS_PROVIDER_PROFILE := profile
diff --git a/testdata/v2_full_yaml/terraform/envs/staging/vpc/Makefile b/testdata/v2_full_yaml/terraform/envs/staging/vpc/Makefile
index 2b3d78bb..4a8d1eee 100644
--- a/testdata/v2_full_yaml/terraform/envs/staging/vpc/Makefile
+++ b/testdata/v2_full_yaml/terraform/envs/staging/vpc/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 0.100.0
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := profile
 
 export AWS_PROVIDER_PROFILE := profile
diff --git a/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/Makefile b/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/Makefile
index 9f54891d..3a7c96b4 100644
--- a/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/Makefile
+++ b/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/Makefile
@@ -4,6 +4,7 @@
 export TERRAFORM_VERSION := 0.100.0
 export TFLINT_ENABLED := 0
 export TF_PLUGIN_CACHE_DIR := ../../../..//.terraform.d/plugin-cache
+export TF_BACKEND_KIND := s3
 export AWS_BACKEND_PROFILE := profile