Repository: chanzuckerberg/fogg
Pull request #478 (2020-05-27 17:35:12)

[feature] add account name variable
Add a `account` variable to account components which includes the name
of the account, as defined by fogg.yml.

### Test Plan
* CI

### References

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

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

```diff
@@           Coverage Diff           @@
##           master     #478   +/-   ##
=======================================
  Coverage   59.36%   59.36%           
=======================================
  Files          19       19           
  Lines        1996     1996           
=======================================
  Hits         1185     1185           
  Misses        653      653           
  Partials      158      158           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/478?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/478?src=pr&el=footer). Last update [1dea7f6...fca04dc](https://codecov.io/gh/chanzuckerberg/fogg/pull/478?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 26a8b8cc..bf44a624 100644
--- a/templates/account/fogg.tf.tmpl
+++ b/templates/account/fogg.tf.tmpl
@@ -67,6 +67,11 @@ variable owner {
   default = "{{ .Owner }}"
 }
 
+variable account {
+    type = string
+    default = "{{ .AccountName }}
+}
+
 # map of aws_accounts
 variable aws_accounts {
   type =  map


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 f5b61068..769b93ac 100644
--- a/testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -40,44 +40,48 @@ variable owner {
   type    = string
   default = "foo@example.com"
 }
+variable account {
+  type    = string
+  default = "foo
+}
 # map of aws_accounts
 variable aws_accounts {
-  type = map
+  type =  map
   default = {
-
-
-
+  
+    
+  
   }
 }
 data terraform_remote_state global {
-  backend = "s3"
+  backend = " s3 "
   config = {
-
-
-    bucket = "bucket"
-
-    key     = "terraform/foofoo/global.tfstate"
-    region  = "region"
-    profile = "foofoo"
-
-
+    
+  
+    bucket         = " bucket "
+    
+    key            = " terraform / foofoo / global.tfstate "
+    region = " region "
+    profile = " foofoo "
+    
+  
   }
 }
 provider random {
-  version = "~> 2.2"
+  version = " ~ > 2.2 "
 }
 provider template {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider archive {
-  version = "~> 1.3"
+  version = " ~ > 1.3 "
 }
 provider null {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider local {
-  version = "~> 1.4"
+  version = " ~ > 1.4 "
 }
 provider tls {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
diff --git a/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf
index 98f696cf..2dd15bb2 100644
--- a/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -27,44 +27,48 @@ variable owner {
   type    = string
   default = "foo@example.com"
 }
+variable account {
+  type    = string
+  default = "foo
+}
 # map of aws_accounts
 variable aws_accounts {
-  type = map
+  type =  map
   default = {
-
-
-
+  
+    
+  
   }
 }
 data terraform_remote_state global {
-  backend = "s3"
+  backend = " s3 "
   config = {
-
-
-    bucket = "bucket"
-
-    key     = "terraform/foo/global.tfstate"
-    region  = "region"
-    profile = "foo"
-
-
+    
+  
+    bucket         = " bucket "
+    
+    key            = " terraform / foo / global.tfstate "
+    region = " region "
+    profile = " foo "
+    
+  
   }
 }
 provider random {
-  version = "~> 2.2"
+  version = " ~ > 2.2 "
 }
 provider template {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider archive {
-  version = "~> 1.3"
+  version = " ~ > 1.3 "
 }
 provider null {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider local {
-  version = "~> 1.4"
+  version = " ~ > 1.4 "
 }
 provider tls {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
diff --git a/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf
index 2bc7676d..437e38aa 100644
--- a/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -28,44 +28,48 @@ variable owner {
   type    = string
   default = "foo@example.com"
 }
+variable account {
+  type    = string
+  default = "foo
+}
 # map of aws_accounts
 variable aws_accounts {
-  type = map
+  type =  map
   default = {
-
-
-
+  
+    
+  
   }
 }
 data terraform_remote_state global {
-  backend = "s3"
+  backend = " s3 "
   config = {
-
-
-    bucket = "bucket"
-
-    key     = "terraform/foofoo/global.tfstate"
-    region  = "region"
-    profile = "foofoo"
-
-
+    
+  
+    bucket         = " bucket "
+    
+    key            = " terraform / foofoo / global.tfstate "
+    region = " region "
+    profile = " foofoo "
+    
+  
   }
 }
 provider random {
-  version = "~> 2.2"
+  version = " ~ > 2.2 "
 }
 provider template {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider archive {
-  version = "~> 1.3"
+  version = " ~ > 1.3 "
 }
 provider null {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider local {
-  version = "~> 1.4"
+  version = " ~ > 1.4 "
 }
 provider tls {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
diff --git a/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf
index fb47fdb6..37ff5dec 100644
--- a/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -28,44 +28,48 @@ variable owner {
   type    = string
   default = "foo@example.com"
 }
+variable account {
+  type    = string
+  default = "foo
+}
 # map of aws_accounts
 variable aws_accounts {
-  type = map
+  type =  map
   default = {
-
-
-
+  
+    
+  
   }
 }
 data terraform_remote_state global {
-  backend = "s3"
+  backend = " s3 "
   config = {
-
-
-    bucket = "bucket"
-
-    key     = "terraform/foo/global.tfstate"
-    region  = "region"
-    profile = "foo"
-
-
+    
+  
+    bucket         = " bucket "
+    
+    key            = " terraform / foo / global.tfstate "
+    region = " region "
+    profile = " foo "
+    
+  
   }
 }
 provider random {
-  version = "~> 2.2"
+  version = " ~ > 2.2 "
 }
 provider template {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider archive {
-  version = "~> 1.3"
+  version = " ~ > 1.3 "
 }
 provider null {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider local {
-  version = "~> 1.4"
+  version = " ~ > 1.4 "
 }
 provider tls {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
diff --git a/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf
index 00e0f675..79a07dfc 100644
--- a/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -26,44 +26,48 @@ variable owner {
   type    = string
   default = "foo@example.com"
 }
+variable account {
+  type    = string
+  default = "foo
+}
 # map of aws_accounts
 variable aws_accounts {
-  type = map
+  type =  map
   default = {
-
-
-
+  
+    
+  
   }
 }
 data terraform_remote_state global {
-  backend = "s3"
+  backend = " s3 "
   config = {
-
-
-    bucket = "bucket"
-
-    key     = "terraform/foo/global.tfstate"
-    region  = "region"
-    profile = "foo"
-
-
+    
+  
+    bucket         = " bucket "
+    
+    key            = " terraform / foo / global.tfstate "
+    region = " region "
+    profile = " foo "
+    
+  
   }
 }
 provider random {
-  version = "~> 2.2"
+  version = " ~ > 2.2 "
 }
 provider template {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider archive {
-  version = "~> 1.3"
+  version = " ~ > 1.3 "
 }
 provider null {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider local {
-  version = "~> 1.4"
+  version = " ~ > 1.4 "
 }
 provider tls {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
diff --git a/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf b/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf
index 1e05ec84..61c96046 100644
--- a/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf
@@ -68,68 +68,72 @@ variable owner {
   type    = string
   default = "foo@example.com"
 }
+variable account {
+  type    = string
+  default = "bar
+}
 # map of aws_accounts
 variable aws_accounts {
-  type = map
+  type =  map
   default = {
-
-
-    bar = 456
-
-
-
-    foo = 123
-
-
+  
+    
+        bar = 456
+    
+  
+    
+        foo = 123
+    
+  
   }
 }
 variable foo {
-  type    = string
-  default = "bar1"
+  type =  string
+  default = " bar1 "
 }
 data terraform_remote_state global {
-  backend = "s3"
+  backend = " s3 "
   config = {
-
-
-    bucket = "buck"
-
-    key     = "terraform/proj/global.tfstate"
-    region  = "us-west-2"
-    profile = "profile"
-
-
+    
+  
+    bucket         = " buck "
+    
+    key            = " terraform / proj / global.tfstate "
+    region = " us-west-2 "
+    profile = " profile "
+    
+  
   }
 }
 data terraform_remote_state foo {
-  backend = "s3"
+  backend = " s3 "
   config = {
-
-
-    bucket = "buck"
-
-    key     = "terraform/proj/accounts/foo.tfstate"
-    region  = "us-west-2"
-    profile = "profile"
-
-
+    
+  
+    bucket         = " buck "
+    
+    key            = " terraform / proj / accounts / foo.tfstate "
+    region = " us-west-2 "
+    profile = " profile "
+    
+  
   }
 }
 provider random {
-  version = "~> 2.2"
+  version = " ~ > 2.2 "
 }
 provider template {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider archive {
-  version = "~> 1.3"
+  version = " ~ > 1.3 "
 }
 provider null {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider local {
-  version = "~> 1.4"
+  version = " ~ > 1.4 "
 }
 provider tls {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
diff --git a/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf b/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf
index 186cab59..baa435b4 100644
--- a/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf
@@ -40,68 +40,72 @@ variable owner {
   type    = string
   default = "foo@example.com"
 }
+variable account {
+  type    = string
+  default = "foo
+}
 # map of aws_accounts
 variable aws_accounts {
-  type = map
+  type =  map
   default = {
-
-
-    bar = 456
-
-
-
-    foo = 123
-
-
+  
+    
+        bar = 456
+    
+  
+    
+        foo = 123
+    
+  
   }
 }
 variable foo {
-  type    = string
-  default = "bar1"
+  type =  string
+  default = " bar1 "
 }
 data terraform_remote_state global {
-  backend = "s3"
+  backend = " s3 "
   config = {
-
-
-    bucket = "buck"
-
-    key     = "terraform/proj/global.tfstate"
-    region  = "us-west-2"
-    profile = "profile"
-
-
+    
+  
+    bucket         = " buck "
+    
+    key            = " terraform / proj / global.tfstate "
+    region = " us-west-2 "
+    profile = " profile "
+    
+  
   }
 }
 data terraform_remote_state bar {
-  backend = "s3"
+  backend = " s3 "
   config = {
-
-
-    bucket = "buck"
-
-    key     = "terraform/proj/accounts/bar.tfstate"
-    region  = "us-west-2"
-    profile = "profile"
-
-
+    
+  
+    bucket         = " buck "
+    
+    key            = " terraform / proj / accounts / bar.tfstate "
+    region = " us-west-2 "
+    profile = " profile "
+    
+  
   }
 }
 provider random {
-  version = "~> 2.2"
+  version = " ~ > 2.2 "
 }
 provider template {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider archive {
-  version = "~> 1.3"
+  version = " ~ > 1.3 "
 }
 provider null {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }
 provider local {
-  version = "~> 1.4"
+  version = " ~ > 1.4 "
 }
 provider tls {
-  version = "~> 2.1"
+  version = " ~ > 2.1 "
 }