Repository: chanzuckerberg/fogg
Pull request #511 (2020-12-22 19:28:40)

[fix] issue with fetching wrong depends_on
Was using the wrong getter for resolving account dependencies in env
components. Really need to refact the plannig code to be more DRY.

### Test Plan
* updated golden file tests
* tested with idseq-infra

### References

codecov-io: # [Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/511?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`main@32e7f10`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##             main     #511   +/-   ##
=======================================
  Coverage        ?   56.89%           
=======================================
  Files           ?       21           
  Lines           ?     1930           
  Branches        ?        0           
=======================================
  Hits            ?     1098           
  Misses          ?      664           
  Partials        ?      168           
```



------

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


Patch:
diff --git a/plan/plan.go b/plan/plan.go
index d57d0171..be0ee8a7 100644
--- a/plan/plan.go
+++ b/plan/plan.go
@@ -327,7 +327,6 @@ func (p *Plan) buildAccounts(c *v2.Config) map[string]Account {
 	}
 
 	for name, acct := range c.Accounts {
-
 		accountRemoteStates := v2.ResolveOptionalStringSlice(v2.DependsOnAccountsGetter, defaults.Common, acct.Common)
 		a := accountPlans[name]
 		filtered := map[string]Backend{}
@@ -400,7 +399,7 @@ func (p *Plan) buildEnvs(conf *v2.Config) (map[string]Env, error) {
 		envPlan.Env = envName
 
 		for componentName, componentConf := range conf.Envs[envName].Components {
-			accountRemoteStates := v2.ResolveOptionalStringSlice(v2.DependsOnComponentsGetter, defaults.Common, envConf.Common, componentConf.Common)
+			accountRemoteStates := v2.ResolveOptionalStringSlice(v2.DependsOnAccountsGetter, defaults.Common, envConf.Common, componentConf.Common)
 
 			componentPlan := Component{
 				Kind: componentConf.Kind,


Test patch:
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 4e95246a..46f3bc5f 100644
--- a/testdata/v2_full_yaml/terraform/envs/prod/datadog/fogg.tf
+++ b/testdata/v2_full_yaml/terraform/envs/prod/datadog/fogg.tf
@@ -95,20 +95,6 @@ data terraform_remote_state hero {
   }
 }
 # remote state for accounts
-data terraform_remote_state foo {
-  backend = "s3"
-  config = {
-
-
-    bucket = "buck"
-
-    key     = "terraform/proj/accounts/foo.tfstate"
-    region  = "us-west-2"
-    profile = "profile"
-
-
-  }
-}
 # map of aws_accounts
 variable aws_accounts {
   type = map