Repository: chanzuckerberg/fogg
Pull request #399 (2020-02-03 21:59:42)

[feature] pin null provider version
We now pin the version of the terraform null provider. The version is hard-coded, but we can make it configurable when we need to.

This is part of efforts to have reproducible runs & reduce noise in terraform's output.

### Test Plan
* travis-ci

### References
*


codecov[bot]: # [Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/399?src=pr&el=h1) Report
> Merging [#399](https://codecov.io/gh/chanzuckerberg/fogg/pull/399?src=pr&el=desc) into [master](https://codecov.io/gh/chanzuckerberg/fogg/commit/d61f096111a964343843619fa051691e8714bc57?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/chanzuckerberg/fogg/pull/399/graphs/tree.svg?width=650&token=57DhtZ7g2A&height=150&src=pr)](https://codecov.io/gh/chanzuckerberg/fogg/pull/399?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #399   +/-   ##
=======================================
  Coverage   79.22%   79.22%           
=======================================
  Files          25       25           
  Lines        2026     2026           
=======================================
  Hits         1605     1605           
  Misses        278      278           
  Partials      143      143
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/399?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/399?src=pr&el=footer). Last update [d61f096...9bf9533](https://codecov.io/gh/chanzuckerberg/fogg/pull/399?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/templates/account/fogg.tf.tmpl b/templates/account/fogg.tf.tmpl
index e258bfd7..d2b4591c 100644
--- a/templates/account/fogg.tf.tmpl
+++ b/templates/account/fogg.tf.tmpl
@@ -127,14 +127,4 @@ data "terraform_remote_state" "{{ $accountName }}" {
 {{ end }}
 {{ end }}
 
-provider random {
-  version = "~> 2.2"
-}
-
-provider template {
-  version = "~> 2.1"
-}
-
-provider archive {
-  version = "~> 1.3"
-}
+{{ template "common_providers" }}
diff --git a/templates/common/common_providers.tmpl b/templates/common/common_providers.tmpl
new file mode 100644
index 00000000..8c8dd4ec
--- /dev/null
+++ b/templates/common/common_providers.tmpl
@@ -0,0 +1,17 @@
+{{ define "common_providers" -}}
+provider random {
+  version = "~> 2.2"
+}
+
+provider template {
+  version = "~> 2.1"
+}
+
+provider archive {
+  version = "~> 1.3"
+}
+
+provider null {
+  version = "~> 2.1"
+}
+{{- end }}
diff --git a/templates/component/terraform/fogg.tf.tmpl b/templates/component/terraform/fogg.tf.tmpl
index dfec5cef..4c322b86 100644
--- a/templates/component/terraform/fogg.tf.tmpl
+++ b/templates/component/terraform/fogg.tf.tmpl
@@ -170,14 +170,4 @@ variable "aws_accounts" {
   }
 }
 
-provider random {
-  version = "~> 2.2"
-}
-
-provider template {
-  version = "~> 2.1"
-}
-
-provider archive {
-  version = "~> 1.3"
-}
+{{ template "common_providers" }}
diff --git a/templates/global/fogg.tf.tmpl b/templates/global/fogg.tf.tmpl
index c48507a0..5b2cb055 100644
--- a/templates/global/fogg.tf.tmpl
+++ b/templates/global/fogg.tf.tmpl
@@ -129,14 +129,4 @@ data "terraform_remote_state" "{{ $component }}" {
 }
 {{ end }}
 
-provider random {
-  version = "~> 2.2"
-}
-
-provider template {
-  version = "~> 2.1"
-}
-
-provider archive {
-  version = "~> 1.3"
-}
+{{ template "common_providers" }}


Test patch:
diff --git a/templates/templates_test.go b/templates/templates_test.go
index b020bd8f..1d587904 100644
--- a/templates/templates_test.go
+++ b/templates/templates_test.go
@@ -21,7 +21,7 @@ func TestOpenTemplate(t *testing.T) {
 		tLen    int
 		wantErr bool
 	}{
-		{"foo", args{temps.Account, "Makefile.tmpl"}, 8, false},
+		{"foo", args{temps.Account, "Makefile.tmpl"}, 9, false},
 	}
 
 	for _, tt := range tests {
diff --git a/testdata/bless_provider/terraform/accounts/foo/fogg.tf b/testdata/bless_provider/terraform/accounts/foo/fogg.tf
index edf12c0c..abf3f415 100644
--- a/testdata/bless_provider/terraform/accounts/foo/fogg.tf
+++ b/testdata/bless_provider/terraform/accounts/foo/fogg.tf
@@ -104,3 +104,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/bless_provider/terraform/envs/bar/bam/fogg.tf b/testdata/bless_provider/terraform/envs/bar/bam/fogg.tf
index 60912eea..1793e16b 100644
--- a/testdata/bless_provider/terraform/envs/bar/bam/fogg.tf
+++ b/testdata/bless_provider/terraform/envs/bar/bam/fogg.tf
@@ -143,3 +143,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/bless_provider/terraform/global/fogg.tf b/testdata/bless_provider/terraform/global/fogg.tf
index 873be5c1..b0864753 100644
--- a/testdata/bless_provider/terraform/global/fogg.tf
+++ b/testdata/bless_provider/terraform/global/fogg.tf
@@ -105,3 +105,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/github_provider/terraform/accounts/foo/fogg.tf b/testdata/github_provider/terraform/accounts/foo/fogg.tf
index 5ca238c1..3d17c512 100644
--- a/testdata/github_provider/terraform/accounts/foo/fogg.tf
+++ b/testdata/github_provider/terraform/accounts/foo/fogg.tf
@@ -88,3 +88,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/github_provider/terraform/envs/bar/bam/fogg.tf b/testdata/github_provider/terraform/envs/bar/bam/fogg.tf
index 4d1e5d5d..6c1c80ce 100644
--- a/testdata/github_provider/terraform/envs/bar/bam/fogg.tf
+++ b/testdata/github_provider/terraform/envs/bar/bam/fogg.tf
@@ -127,3 +127,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/github_provider/terraform/global/fogg.tf b/testdata/github_provider/terraform/global/fogg.tf
index 0c2fdf0e..626b73d2 100644
--- a/testdata/github_provider/terraform/global/fogg.tf
+++ b/testdata/github_provider/terraform/global/fogg.tf
@@ -89,3 +89,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/okta_provider/terraform/accounts/foo/fogg.tf b/testdata/okta_provider/terraform/accounts/foo/fogg.tf
index a0676080..75b9888e 100644
--- a/testdata/okta_provider/terraform/accounts/foo/fogg.tf
+++ b/testdata/okta_provider/terraform/accounts/foo/fogg.tf
@@ -88,3 +88,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/okta_provider/terraform/envs/bar/bam/fogg.tf b/testdata/okta_provider/terraform/envs/bar/bam/fogg.tf
index 0a4d48a4..5063322d 100644
--- a/testdata/okta_provider/terraform/envs/bar/bam/fogg.tf
+++ b/testdata/okta_provider/terraform/envs/bar/bam/fogg.tf
@@ -127,3 +127,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/okta_provider/terraform/global/fogg.tf b/testdata/okta_provider/terraform/global/fogg.tf
index 790f81ae..88bf6dbc 100644
--- a/testdata/okta_provider/terraform/global/fogg.tf
+++ b/testdata/okta_provider/terraform/global/fogg.tf
@@ -89,3 +89,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/snowflake_provider/terraform/accounts/foo/fogg.tf b/testdata/snowflake_provider/terraform/accounts/foo/fogg.tf
index 4f0a599c..749430a3 100644
--- a/testdata/snowflake_provider/terraform/accounts/foo/fogg.tf
+++ b/testdata/snowflake_provider/terraform/accounts/foo/fogg.tf
@@ -89,3 +89,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/snowflake_provider/terraform/envs/bar/bam/fogg.tf b/testdata/snowflake_provider/terraform/envs/bar/bam/fogg.tf
index ba00916f..b0ea4349 100644
--- a/testdata/snowflake_provider/terraform/envs/bar/bam/fogg.tf
+++ b/testdata/snowflake_provider/terraform/envs/bar/bam/fogg.tf
@@ -128,3 +128,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/snowflake_provider/terraform/global/fogg.tf b/testdata/snowflake_provider/terraform/global/fogg.tf
index b6a68548..e3cda70d 100644
--- a/testdata/snowflake_provider/terraform/global/fogg.tf
+++ b/testdata/snowflake_provider/terraform/global/fogg.tf
@@ -90,3 +90,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v1_full/terraform/accounts/bar/fogg.tf b/testdata/v1_full/terraform/accounts/bar/fogg.tf
index dea69626..cf7663e8 100644
--- a/testdata/v1_full/terraform/accounts/bar/fogg.tf
+++ b/testdata/v1_full/terraform/accounts/bar/fogg.tf
@@ -133,3 +133,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v1_full/terraform/accounts/foo/fogg.tf b/testdata/v1_full/terraform/accounts/foo/fogg.tf
index ef94ca2e..51535ef5 100644
--- a/testdata/v1_full/terraform/accounts/foo/fogg.tf
+++ b/testdata/v1_full/terraform/accounts/foo/fogg.tf
@@ -133,3 +133,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v1_full/terraform/envs/stage/cloud-env/fogg.tf b/testdata/v1_full/terraform/envs/stage/cloud-env/fogg.tf
index 4b50b3d6..7b794195 100644
--- a/testdata/v1_full/terraform/envs/stage/cloud-env/fogg.tf
+++ b/testdata/v1_full/terraform/envs/stage/cloud-env/fogg.tf
@@ -183,3 +183,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v1_full/terraform/envs/stage/helm/fogg.tf b/testdata/v1_full/terraform/envs/stage/helm/fogg.tf
index 2a259ba9..a368a3ee 100644
--- a/testdata/v1_full/terraform/envs/stage/helm/fogg.tf
+++ b/testdata/v1_full/terraform/envs/stage/helm/fogg.tf
@@ -183,3 +183,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v1_full/terraform/global/fogg.tf b/testdata/v1_full/terraform/global/fogg.tf
index ea3148d0..5812ff83 100644
--- a/testdata/v1_full/terraform/global/fogg.tf
+++ b/testdata/v1_full/terraform/global/fogg.tf
@@ -114,3 +114,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_full/terraform/accounts/bar/fogg.tf b/testdata/v2_full/terraform/accounts/bar/fogg.tf
index b8f910e9..0550f28e 100644
--- a/testdata/v2_full/terraform/accounts/bar/fogg.tf
+++ b/testdata/v2_full/terraform/accounts/bar/fogg.tf
@@ -125,3 +125,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_full/terraform/accounts/foo/fogg.tf b/testdata/v2_full/terraform/accounts/foo/fogg.tf
index 0225a45a..5acd4103 100644
--- a/testdata/v2_full/terraform/accounts/foo/fogg.tf
+++ b/testdata/v2_full/terraform/accounts/foo/fogg.tf
@@ -125,3 +125,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_full/terraform/envs/staging/comp1/fogg.tf b/testdata/v2_full/terraform/envs/staging/comp1/fogg.tf
index ad7e2ed4..f7b51f4b 100644
--- a/testdata/v2_full/terraform/envs/staging/comp1/fogg.tf
+++ b/testdata/v2_full/terraform/envs/staging/comp1/fogg.tf
@@ -187,3 +187,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_full/terraform/envs/staging/comp2/fogg.tf b/testdata/v2_full/terraform/envs/staging/comp2/fogg.tf
index bdd5f044..80852bd7 100644
--- a/testdata/v2_full/terraform/envs/staging/comp2/fogg.tf
+++ b/testdata/v2_full/terraform/envs/staging/comp2/fogg.tf
@@ -187,3 +187,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_full/terraform/envs/staging/vpc/fogg.tf b/testdata/v2_full/terraform/envs/staging/vpc/fogg.tf
index 30d8d31b..a0e6383f 100644
--- a/testdata/v2_full/terraform/envs/staging/vpc/fogg.tf
+++ b/testdata/v2_full/terraform/envs/staging/vpc/fogg.tf
@@ -187,3 +187,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_full/terraform/global/fogg.tf b/testdata/v2_full/terraform/global/fogg.tf
index 2813cabf..8b36e04d 100644
--- a/testdata/v2_full/terraform/global/fogg.tf
+++ b/testdata/v2_full/terraform/global/fogg.tf
@@ -106,3 +106,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_minimal_valid/terraform/global/fogg.tf b/testdata/v2_minimal_valid/terraform/global/fogg.tf
index 1fbccd1c..5d276d27 100644
--- a/testdata/v2_minimal_valid/terraform/global/fogg.tf
+++ b/testdata/v2_minimal_valid/terraform/global/fogg.tf
@@ -80,3 +80,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_no_aws_provider/terraform/accounts/bar/fogg.tf b/testdata/v2_no_aws_provider/terraform/accounts/bar/fogg.tf
index c70b643d..29ac8811 100644
--- a/testdata/v2_no_aws_provider/terraform/accounts/bar/fogg.tf
+++ b/testdata/v2_no_aws_provider/terraform/accounts/bar/fogg.tf
@@ -100,3 +100,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_no_aws_provider/terraform/accounts/foo/fogg.tf b/testdata/v2_no_aws_provider/terraform/accounts/foo/fogg.tf
index e45267d6..1b8e5f88 100644
--- a/testdata/v2_no_aws_provider/terraform/accounts/foo/fogg.tf
+++ b/testdata/v2_no_aws_provider/terraform/accounts/foo/fogg.tf
@@ -100,3 +100,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_no_aws_provider/terraform/envs/staging/comp1/fogg.tf b/testdata/v2_no_aws_provider/terraform/envs/staging/comp1/fogg.tf
index 8fce6e78..9b6c06ba 100644
--- a/testdata/v2_no_aws_provider/terraform/envs/staging/comp1/fogg.tf
+++ b/testdata/v2_no_aws_provider/terraform/envs/staging/comp1/fogg.tf
@@ -161,3 +161,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_no_aws_provider/terraform/envs/staging/comp2/fogg.tf b/testdata/v2_no_aws_provider/terraform/envs/staging/comp2/fogg.tf
index db252d69..0d74228a 100644
--- a/testdata/v2_no_aws_provider/terraform/envs/staging/comp2/fogg.tf
+++ b/testdata/v2_no_aws_provider/terraform/envs/staging/comp2/fogg.tf
@@ -161,3 +161,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_no_aws_provider/terraform/envs/staging/vpc/fogg.tf b/testdata/v2_no_aws_provider/terraform/envs/staging/vpc/fogg.tf
index 8a91660d..40bebeee 100644
--- a/testdata/v2_no_aws_provider/terraform/envs/staging/vpc/fogg.tf
+++ b/testdata/v2_no_aws_provider/terraform/envs/staging/vpc/fogg.tf
@@ -161,3 +161,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}
diff --git a/testdata/v2_no_aws_provider/terraform/global/fogg.tf b/testdata/v2_no_aws_provider/terraform/global/fogg.tf
index 9ae0729e..0474fed5 100644
--- a/testdata/v2_no_aws_provider/terraform/global/fogg.tf
+++ b/testdata/v2_no_aws_provider/terraform/global/fogg.tf
@@ -85,3 +85,7 @@ provider template {
 provider archive {
   version = "~> 1.3"
 }
+
+provider null {
+  version = "~> 2.1"
+}