Repository: chanzuckerberg/fogg
Pull request #492 (2020-08-11 14:58:53)

[feature] templates: type var.tags as an object rather than a map
### Summary
Change the automatically generated var.tags from a type of `map(string)` to an `object` type. This lets us make stronger assertions in modules that might want to accept these tag objects.

I found this while trying to write a new module:
```
variable tags {
  description = "Standard tags. Typically generated by fogg."
  # type        = object({ env : string, owner : string, project : string, service : string })
  # NOTE: fogg.tf types this as a map(string) rather than an object. Have to fix there first.
  type = map(string)
}
```

### Test Plan
Unit tests

### References

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

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

```diff
@@           Coverage Diff           @@
##           master     #492   +/-   ##
=======================================
  Coverage   59.27%   59.27%           
=======================================
  Files          19       19           
  Lines        1994     1994           
=======================================
  Hits         1182     1182           
  Misses        654      654           
  Partials      158      158           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/492?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/492?src=pr&el=footer). Last update [97adbc3...6e44a32](https://codecov.io/gh/chanzuckerberg/fogg/pull/492?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

ryanking: @edulop91 can you manually test this on at least 1 repo?
edulop91: > @edulop91 can you manually test this on at least 1 repo?

verified in an internal repo in the new module i'm working on

Patch:
diff --git a/templates/account/fogg.tf.tmpl b/templates/account/fogg.tf.tmpl
index 23d10727..0e3be794 100644
--- a/templates/account/fogg.tf.tmpl
+++ b/templates/account/fogg.tf.tmpl
@@ -73,7 +73,7 @@ variable account {
 }
 
 variable tags {
-  type =  map(string)
+  type =  object({project: string, env: string, service: string, owner: string, managedBy: string})
   default = {
     project   = "{{ .Project }}"
     env       = "accounts"
diff --git a/templates/component/terraform/fogg.tf.tmpl b/templates/component/terraform/fogg.tf.tmpl
index 0f57c630..5619caf7 100644
--- a/templates/component/terraform/fogg.tf.tmpl
+++ b/templates/component/terraform/fogg.tf.tmpl
@@ -80,7 +80,7 @@ variable owner {
 }
 
 variable tags {
-  type =  map(string)
+  type =  object({project: string, env: string, service: string, owner: string, managedBy: string})
   default = {
     project   = "{{ .Project }}"
     env       = "{{ .Env }}"
diff --git a/templates/global/fogg.tf.tmpl b/templates/global/fogg.tf.tmpl
index b9b3a5fa..9de76228 100644
--- a/templates/global/fogg.tf.tmpl
+++ b/templates/global/fogg.tf.tmpl
@@ -76,7 +76,7 @@ variable owner {
 }
 
 variable tags {
-  type =  map(string)
+  type =  object({project: string, env: string, service: string, owner: string, managedBy: string})
   default = {
     project   = "{{ .Project }}"
     env       = "{{ .Env }}"


Test patch:
diff --git a/testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf
index 4e442e34..ef020a8b 100644
--- a/testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -45,7 +45,7 @@ variable account {
   default = "foo"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foofoo"
     env       = "accounts"
diff --git a/testdata/bless_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/bless_provider_yaml/terraform/envs/bar/bam/fogg.tf
index 0f361de1..d39a1396 100644
--- a/testdata/bless_provider_yaml/terraform/envs/bar/bam/fogg.tf
+++ b/testdata/bless_provider_yaml/terraform/envs/bar/bam/fogg.tf
@@ -50,7 +50,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foofoo"
     env       = "bar"
diff --git a/testdata/bless_provider_yaml/terraform/global/fogg.tf b/testdata/bless_provider_yaml/terraform/global/fogg.tf
index 3e3b46da..df6ec224 100644
--- a/testdata/bless_provider_yaml/terraform/global/fogg.tf
+++ b/testdata/bless_provider_yaml/terraform/global/fogg.tf
@@ -50,7 +50,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foofoo"
     env       = ""
diff --git a/testdata/circleci/terraform/global/fogg.tf b/testdata/circleci/terraform/global/fogg.tf
index a3e0ba5b..540c57ec 100644
--- a/testdata/circleci/terraform/global/fogg.tf
+++ b/testdata/circleci/terraform/global/fogg.tf
@@ -32,7 +32,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = ""
diff --git a/testdata/github_actions/terraform/global/fogg.tf b/testdata/github_actions/terraform/global/fogg.tf
index a3e0ba5b..540c57ec 100644
--- a/testdata/github_actions/terraform/global/fogg.tf
+++ b/testdata/github_actions/terraform/global/fogg.tf
@@ -32,7 +32,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = ""
diff --git a/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf
index d0cf5e7e..5f2671bf 100644
--- a/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -32,7 +32,7 @@ variable account {
   default = "foo"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = "accounts"
diff --git a/testdata/github_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/github_provider_yaml/terraform/envs/bar/bam/fogg.tf
index 63a94344..679fb5eb 100644
--- a/testdata/github_provider_yaml/terraform/envs/bar/bam/fogg.tf
+++ b/testdata/github_provider_yaml/terraform/envs/bar/bam/fogg.tf
@@ -37,7 +37,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = "bar"
diff --git a/testdata/github_provider_yaml/terraform/global/fogg.tf b/testdata/github_provider_yaml/terraform/global/fogg.tf
index bcad3c24..45d5b319 100644
--- a/testdata/github_provider_yaml/terraform/global/fogg.tf
+++ b/testdata/github_provider_yaml/terraform/global/fogg.tf
@@ -37,7 +37,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = ""
diff --git a/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf
index 87c06d78..8ce17f46 100644
--- a/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -34,7 +34,7 @@ variable account {
   default = "foo"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foofoo"
     env       = "accounts"
diff --git a/testdata/okta_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/okta_provider_yaml/terraform/envs/bar/bam/fogg.tf
index fca66b02..d117787b 100644
--- a/testdata/okta_provider_yaml/terraform/envs/bar/bam/fogg.tf
+++ b/testdata/okta_provider_yaml/terraform/envs/bar/bam/fogg.tf
@@ -39,7 +39,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foofoo"
     env       = "bar"
diff --git a/testdata/okta_provider_yaml/terraform/global/fogg.tf b/testdata/okta_provider_yaml/terraform/global/fogg.tf
index ce039302..746dc33a 100644
--- a/testdata/okta_provider_yaml/terraform/global/fogg.tf
+++ b/testdata/okta_provider_yaml/terraform/global/fogg.tf
@@ -39,7 +39,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foofoo"
     env       = ""
diff --git a/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf
index 18f66790..a3328295 100644
--- a/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -33,7 +33,7 @@ variable account {
   default = "foo"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = "accounts"
diff --git a/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/fogg.tf
index eb1056b1..9cd3264b 100644
--- a/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/fogg.tf
+++ b/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/fogg.tf
@@ -38,7 +38,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = "bar"
diff --git a/testdata/snowflake_provider_yaml/terraform/global/fogg.tf b/testdata/snowflake_provider_yaml/terraform/global/fogg.tf
index de8ade24..4bc10e6b 100644
--- a/testdata/snowflake_provider_yaml/terraform/global/fogg.tf
+++ b/testdata/snowflake_provider_yaml/terraform/global/fogg.tf
@@ -38,7 +38,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = ""
diff --git a/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf
index bcc749c7..8e3ca1d0 100644
--- a/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -31,7 +31,7 @@ variable account {
   default = "foo"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = "accounts"
diff --git a/testdata/tfe_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/tfe_provider_yaml/terraform/envs/bar/bam/fogg.tf
index be432107..dff73481 100644
--- a/testdata/tfe_provider_yaml/terraform/envs/bar/bam/fogg.tf
+++ b/testdata/tfe_provider_yaml/terraform/envs/bar/bam/fogg.tf
@@ -32,7 +32,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = "bar"
diff --git a/testdata/tfe_provider_yaml/terraform/global/fogg.tf b/testdata/tfe_provider_yaml/terraform/global/fogg.tf
index 86958733..976c289d 100644
--- a/testdata/tfe_provider_yaml/terraform/global/fogg.tf
+++ b/testdata/tfe_provider_yaml/terraform/global/fogg.tf
@@ -36,7 +36,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = ""
diff --git a/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf b/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf
index 4ff27015..c07536ad 100644
--- a/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf
@@ -73,7 +73,7 @@ variable account {
   default = "bar"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = "accounts"
diff --git a/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf b/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf
index 372acda9..c76c6d76 100644
--- a/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf
@@ -45,7 +45,7 @@ variable account {
   default = "foo"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = "accounts"
diff --git a/testdata/v2_full_yaml/terraform/envs/prod/datadog/fogg.tf b/testdata/v2_full_yaml/terraform/envs/prod/datadog/fogg.tf
index 968e08e8..d70432d3 100644
--- a/testdata/v2_full_yaml/terraform/envs/prod/datadog/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/envs/prod/datadog/fogg.tf
@@ -53,7 +53,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = "prod"
diff --git a/testdata/v2_full_yaml/terraform/envs/prod/hero/fogg.tf b/testdata/v2_full_yaml/terraform/envs/prod/hero/fogg.tf
index 62e4684d..792cd917 100644
--- a/testdata/v2_full_yaml/terraform/envs/prod/hero/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/envs/prod/hero/fogg.tf
@@ -53,7 +53,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = "prod"
diff --git a/testdata/v2_full_yaml/terraform/envs/prod/vpc/fogg.tf b/testdata/v2_full_yaml/terraform/envs/prod/vpc/fogg.tf
index 8b256955..c7d14541 100644
--- a/testdata/v2_full_yaml/terraform/envs/prod/vpc/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/envs/prod/vpc/fogg.tf
@@ -50,7 +50,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = "prod"
diff --git a/testdata/v2_full_yaml/terraform/envs/staging/comp1/fogg.tf b/testdata/v2_full_yaml/terraform/envs/staging/comp1/fogg.tf
index 16949b04..ac9e2472 100644
--- a/testdata/v2_full_yaml/terraform/envs/staging/comp1/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/envs/staging/comp1/fogg.tf
@@ -50,7 +50,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = "staging"
diff --git a/testdata/v2_full_yaml/terraform/envs/staging/comp2/fogg.tf b/testdata/v2_full_yaml/terraform/envs/staging/comp2/fogg.tf
index b2bb9d74..893d63ce 100644
--- a/testdata/v2_full_yaml/terraform/envs/staging/comp2/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/envs/staging/comp2/fogg.tf
@@ -50,7 +50,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = "staging"
diff --git a/testdata/v2_full_yaml/terraform/envs/staging/vpc/fogg.tf b/testdata/v2_full_yaml/terraform/envs/staging/vpc/fogg.tf
index 0b052879..eb884686 100644
--- a/testdata/v2_full_yaml/terraform/envs/staging/vpc/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/envs/staging/vpc/fogg.tf
@@ -50,7 +50,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = "staging"
diff --git a/testdata/v2_full_yaml/terraform/global/fogg.tf b/testdata/v2_full_yaml/terraform/global/fogg.tf
index df7dead2..5b46dce6 100644
--- a/testdata/v2_full_yaml/terraform/global/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/global/fogg.tf
@@ -50,7 +50,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = ""
diff --git a/testdata/v2_minimal_valid_yaml/terraform/global/fogg.tf b/testdata/v2_minimal_valid_yaml/terraform/global/fogg.tf
index a3e0ba5b..540c57ec 100644
--- a/testdata/v2_minimal_valid_yaml/terraform/global/fogg.tf
+++ b/testdata/v2_minimal_valid_yaml/terraform/global/fogg.tf
@@ -32,7 +32,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "foo"
     env       = ""
diff --git a/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/fogg.tf b/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/fogg.tf
index 11988c68..aedfc896 100644
--- a/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/fogg.tf
+++ b/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/fogg.tf
@@ -32,7 +32,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = "staging"
diff --git a/testdata/v2_no_aws_provider_yaml/terraform/global/fogg.tf b/testdata/v2_no_aws_provider_yaml/terraform/global/fogg.tf
index ef23a8c1..8e12b158 100644
--- a/testdata/v2_no_aws_provider_yaml/terraform/global/fogg.tf
+++ b/testdata/v2_no_aws_provider_yaml/terraform/global/fogg.tf
@@ -32,7 +32,7 @@ variable owner {
   default = "foo@example.com"
 }
 variable tags {
-  type = map(string)
+  type = object({ project : string, env : string, service : string, owner : string, managedBy : string })
   default = {
     project   = "proj"
     env       = ""