Repository: chanzuckerberg/fogg
Pull request #508 (2020-12-14 18:01:42)

Move the snowflake provider to tf 0.13+ syntax
### Summary
Upgrading the Snowflake provider configuration syntax to 0.13+ style. 

I think there's an open question regarding backward compatibility and how we'd want to think about that. In particular since 0.12 is already 2 versions behind, adding backward compatibility layer might not be worth it? @ryanking what do you think?

### Test Plan
unit tests

### References
- https://www.terraform.io/docs/configuration/providers.html
- https://www.terraform.io/upgrade-guides/0-13.html

codecov-io: # [Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/508?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`main@1704d15`). [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/508/graphs/tree.svg?width=650&height=150&src=pr&token=57DhtZ7g2A)](https://codecov.io/gh/chanzuckerberg/fogg/pull/508?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##             main     #508   +/-   ##
=======================================
  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/508?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/508?src=pr&el=footer). Last update [1704d15...f552ab8](https://codecov.io/gh/chanzuckerberg/fogg/pull/508?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/templates/common/snowflake_provider.tmpl b/templates/common/snowflake_provider.tmpl
index 26e01487..c01d45e8 100644
--- a/templates/common/snowflake_provider.tmpl
+++ b/templates/common/snowflake_provider.tmpl
@@ -1,12 +1,20 @@
 {{define "snowflake_provider"}}
 
+terraform {
+  required_providers {
+    snowflake = {
+      source = "chanzuckerberg/snowflake"
+      {{ if .Version -}}
+      version = "{{ .Version }}"
+      {{ end -}}
+    }
+  }
+}
+
 provider snowflake {
   account = "{{ .Account }}"
   role    = "{{ .Role }}"
   region  = "{{ .Region }}"
-  {{ if .Version -}}
-  version = "~>{{ .Version }}"
-  {{ end -}}
 }
 
 {{ end }}


Test patch:
diff --git a/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf
index f4850454..294399b3 100644
--- a/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf
+++ b/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf
@@ -1,6 +1,13 @@
 # Auto-generated by fogg. Do not edit
 # Make improvements in fogg, so that everyone can benefit.
 
+terraform {
+  required_providers {
+    snowflake = {
+      source = "chanzuckerberg/snowflake"
+    }
+  }
+}
 provider snowflake {
   account = "foo"
   role    = "bar"
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 2589ccb7..eecee584 100644
--- a/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/fogg.tf
+++ b/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/fogg.tf
@@ -1,6 +1,13 @@
 # Auto-generated by fogg. Do not edit
 # Make improvements in fogg, so that everyone can benefit.
 
+terraform {
+  required_providers {
+    snowflake = {
+      source = "chanzuckerberg/snowflake"
+    }
+  }
+}
 provider snowflake {
   account = "foo"
   role    = "bar"
diff --git a/testdata/snowflake_provider_yaml/terraform/global/fogg.tf b/testdata/snowflake_provider_yaml/terraform/global/fogg.tf
index f2cd55aa..95c95aaf 100644
--- a/testdata/snowflake_provider_yaml/terraform/global/fogg.tf
+++ b/testdata/snowflake_provider_yaml/terraform/global/fogg.tf
@@ -1,6 +1,13 @@
 # Auto-generated by fogg. Do not edit
 # Make improvements in fogg, so that everyone can benefit.
 
+terraform {
+  required_providers {
+    snowflake = {
+      source = "chanzuckerberg/snowflake"
+    }
+  }
+}
 provider snowflake {
   account = "foo"
   role    = "bar"