kinvolk / lokomotive

🪦 DISCONTINUED Further Lokomotive development has been discontinued. Lokomotive is a 100% open-source, easy to use and secure Kubernetes distribution from the volks at Kinvolk
https://kinvolk.io/lokomotive-kubernetes/
Apache License 2.0
320 stars 49 forks source link

Don't use provider aliases in Terraform code #539

Closed invidian closed 4 years ago

invidian commented 4 years ago

Terraform recommends modules to specify the required providers and only root module (top level) should instantiate the providers, so it has full control over their configuration.

This means we should do this for all Terraform code:

 module "dns" {
   source = "../lokomotive-kubernetes/dns/{{.Config.DNS.Provider}}"
-  {{ if eq .Config.DNS.Provider "route53" -}}
-  providers = {
-    aws = aws.default
-  }
 }

 provider "aws" {
   version = "2.48.0"
-  alias   = "default"
   # The Route 53 service doesn't need a specific region to operate, however
   # the AWS Terraform provider needs it and the documentation suggests to use
   # "us-east-1": https://docs.aws.amazon.com/general/latest/gr/r53.html.
   region = "us-east-1"
 }

And ensure, that all modules has something like:

# Terraform version and plugin versions

terraform {
  required_version = ">= 0.12"
  required_providers {
    local    = "~> 1.2"
    template = "~> 2.1"
    tls      = "~> 2.0"
  }
}

Note: this may break the updates. See https://github.com/kinvolk/lokomotive/pull/532 for more details.

More refs:

knrt10 commented 4 years ago

On it

knrt10 commented 4 years ago

So this is what I was talking about. Steps to reproduce

cluster.config
```hcl variable "dns_zone" {} variable "packet_project_id" {} variable "ssh_public_keys" {} variable "management_cidrs" {} variable "node_private_cidr" {} variable "cert_manager_email" {} variable "metallb_address_pool" {} variable "asset_dir" { default = "./lokomotive-assets" } variable "facility" { default = "ams1" } variable "cluster_name" { default = "kautilya" } variable "controllers_count" { default = 1 } variable "workers_count" { default = 1 } variable "workers_type" { default = "c2.medium.x86" } cluster "packet" { asset_dir = pathexpand(var.asset_dir) cluster_name = var.cluster_name controller_count = var.controllers_count controller_type = "c2.medium.x86" dns { zone = var.dns_zone provider = "route53" } facility = var.facility project_id = var.packet_project_id ssh_pubkeys = var.ssh_public_keys management_cidrs = var.management_cidrs node_private_cidr = var.node_private_cidr worker_pool "kautilya-pool-1" { count = var.workers_count node_type = var.workers_type } } component "metrics-server" {} component "openebs-operator" {} component "contour" {} component "metallb" { address_pools = { default = var.metallb_address_pool } } component "cert-manager" { email = var.cert_manager_email } component "openebs-storage-class" {} component "prometheus-operator" {} component "flatcar-linux-update-operator" {} ```

kautilya-controller-0 True KubeletReady kubelet is posting ready status kautilya-kautilya-pool-1-worker-0 True KubeletReady kubelet is posting ready status Name Status Message Error

etcd-0 True {"health":"true"}

- Then build the code with below changes

<details>
<summary>Diff changes</summary>
<br>

```diff
diff --git a/pkg/platform/packet/template.go b/pkg/platform/packet/template.go
index d4da1ad0..ff2a4315 100644
--- a/pkg/platform/packet/template.go
+++ b/pkg/platform/packet/template.go
@@ -18,14 +18,6 @@ var terraformConfigTmpl = `
 module "packet-{{.Config.ClusterName}}" {
   source = "../lokomotive-kubernetes/packet/flatcar-linux/kubernetes"

-  providers = {
-    local    = local.default
-    null     = null.default
-    template = template.default
-    tls      = tls.default
-    packet   = packet.default
-  }
-
   dns_zone    = "{{.Config.DNS.Zone}}"

   ssh_keys  = {{.SSHPublicKeys}}
diff --git a/pkg/platform/packet/template.go b/pkg/platform/packet/template.go
diff --git a/pkg/platform/packet/template.go b/pkg/platform/packet/template.go
index d4da1ad0..ff2a4315 100644
--- a/pkg/platform/packet/template.go
+++ b/pkg/platform/packet/template.go
@@ -18,14 +18,6 @@ var terraformConfigTmpl = `
 module "packet-{{.Config.ClusterName}}" {
   source = "../lokomotive-kubernetes/packet/flatcar-linux/kubernetes"

-  providers = {
-    local    = local.default
-    null     = null.default
-    template = template.default
-    tls      = tls.default
-    packet   = packet.default
-  }
-
   dns_zone    = "{{.Config.DNS.Zone}}"

   ssh_keys  = {{.SSHPublicKeys}}
@@ -124,13 +116,6 @@ EOF
 module "worker-{{ $pool.Name }}" {
   source = "../lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers"

-  providers = {
-    local    = local.default
-    template = template.default
-    tls      = tls.default
-    packet   = packet.default
-  }
-
   dns_zone = "{{$.Config.DNS.Zone}}"

   ssh_keys  = {{$.SSHPublicKeys}}
@@ -236,12 +221,6 @@ EOF
 module "dns" {
   source = "../lokomotive-kubernetes/dns/{{.Config.DNS.Provider}}"

-  {{ if eq .Config.DNS.Provider "route53" -}}
-  providers = {
-    aws = aws.default
-  }
-
-  {{ end -}}
   cluster_name             = "{{ .Config.ClusterName }}"
   controllers_public_ipv4  = module.packet-{{.Config.ClusterName}}.controllers_public_ipv4
   controllers_private_ipv4 = module.packet-{{.Config.ClusterName}}.controllers_private_ipv4
@@ -258,7 +237,6 @@ output "dns_entries" {
 {{- if eq .Config.DNS.Provider "route53" }}
 provider "aws" {
   version = "2.48.0"
-  alias   = "default"
   # The Route 53 service doesn't need a specific region to operate, however
   # the AWS Terraform provider needs it and the documentation suggests to use
   # "us-east-1": https://docs.aws.amazon.com/general/latest/gr/r53.html.
@@ -272,27 +250,22 @@ provider "ct" {

 provider "local" {
   version = "1.4.0"
-  alias   = "default"
 }

 provider "null" {
   version = "~> 2.1"
-  alias   = "default"
 }

 provider "template" {
   version = "~> 2.1"
-  alias   = "default"
 }

 provider "tls" {
   version = "~> 2.0"
-  alias   = "default"
 }

 provider "packet" {
   version = "~> 2.7.3"
-  alias = "default"

   {{- if .Config.AuthToken }}
   auth_token = "{{.Config.AuthToken}}"

After this, I get this error when I redeploy and apply new terraform changes

Error preview

It makes 18 retries and exits.

Error

Question

Is this the expected outcome? Is the cluster supposed to give timeout error?

invidian commented 4 years ago

Hm, I was not able to reproduce it, though I didn't start with v0.1.0, but from fa3278af, then applied following patch:

diff --git a/assets/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/versions.tf b/assets/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/versions.tf
new file mode 100644
index 00000000..3ff518e7
--- /dev/null
+++ b/assets/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/versions.tf
@@ -0,0 +1,11 @@
+# Terraform version and plugin versions
+
+terraform {
+  required_version = ">= 0.12.0"
+
+  required_providers {
+    aws      = "2.48.0"
+    ct       = "0.5.0"
+    template = "~> 2.1"
+  }
+}
diff --git a/pkg/platform/aws/template.go b/pkg/platform/aws/template.go
index 828c2da4..4d90616f 100644
--- a/pkg/platform/aws/template.go
+++ b/pkg/platform/aws/template.go
@@ -18,14 +18,6 @@ var terraformConfigTmpl = `
 module "aws-{{.Config.ClusterName}}" {
   source = "../lokomotive-kubernetes/aws/flatcar-linux/kubernetes"

-  providers = {
-    aws      = aws.default
-    local    = local.default
-    null     = null.default
-    template = template.default
-    tls      = tls.default
-  }
-
   cluster_name = "{{.Config.ClusterName}}"
   tags         = {{.Tags}}
   dns_zone     = "{{.Config.DNSZone}}"
@@ -108,10 +100,6 @@ module "aws-{{.Config.ClusterName}}" {
 module "worker-pool-{{ $index }}" {
   source = "../lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers"

-  providers = {
-    aws      = aws.default
-  }
-
   vpc_id                = module.aws-{{ $.Config.ClusterName }}.vpc_id
   subnet_ids            = flatten([module.aws-{{ $.Config.ClusterName }}.subnet_ids])
   security_groups       = module.aws-{{ $.Config.ClusterName }}.worker_security_groups
@@ -182,7 +170,6 @@ module "worker-pool-{{ $index }}" {

 provider "aws" {
   version = "2.48.0"
-  alias   = "default"

   region                  = "{{.Config.Region}}"
   {{- if .Config.CredsPath }}
@@ -196,22 +183,18 @@ provider "ct" {

 provider "local" {
   version = "1.4.0"
-  alias   = "default"
 }

 provider "null" {
   version = "~> 2.1"
-  alias   = "default"
 }

 provider "template" {
   version = "~> 2.1"
-  alias   = "default"
 }

 provider "tls" {
   version = "~> 2.0"
-  alias   = "default"
 }

 # Stub output, which indicates, that Terraform run at least once.

And everything seems to work. Will try to Packet now.

knrt10 commented 4 years ago

Ok, let me try this

knrt10 commented 4 years ago

I tried your patch and same steps, AWS is working fine, but packet still gives error

invidian commented 4 years ago

On Packet things also seems fine with the following patch:

diff --git a/assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/require.tf b/assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/require.tf
index 4a4a17bb..1fce2e1a 100644
--- a/assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/require.tf
+++ b/assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/require.tf
@@ -4,10 +4,7 @@ terraform {
   required_version = ">= 0.12.0"

   required_providers {
-    ct       = "= 0.5.0"
-    local    = "~> 1.2"
-    template = "~> 2.1"
-    tls      = "~> 2.0"
-    packet   = "~> 2.7.3"
+    ct     = "= 0.5.0"
+    packet = "~> 2.7.3"
   }
 }
diff --git a/pkg/platform/packet/template.go b/pkg/platform/packet/template.go
index d4da1ad0..ff2a4315 100644
--- a/pkg/platform/packet/template.go
+++ b/pkg/platform/packet/template.go
@@ -18,14 +18,6 @@ var terraformConfigTmpl = `
 module "packet-{{.Config.ClusterName}}" {
   source = "../lokomotive-kubernetes/packet/flatcar-linux/kubernetes"

-  providers = {
-    local    = local.default
-    null     = null.default
-    template = template.default
-    tls      = tls.default
-    packet   = packet.default
-  }
-
   dns_zone    = "{{.Config.DNS.Zone}}"

   ssh_keys  = {{.SSHPublicKeys}}
@@ -124,13 +116,6 @@ EOF
 module "worker-{{ $pool.Name }}" {
   source = "../lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers"

-  providers = {
-    local    = local.default
-    template = template.default
-    tls      = tls.default
-    packet   = packet.default
-  }
-
   dns_zone = "{{$.Config.DNS.Zone}}"

   ssh_keys  = {{$.SSHPublicKeys}}
@@ -236,12 +221,6 @@ EOF
 module "dns" {
   source = "../lokomotive-kubernetes/dns/{{.Config.DNS.Provider}}"

-  {{ if eq .Config.DNS.Provider "route53" -}}
-  providers = {
-    aws = aws.default
-  }
-
-  {{ end -}}
   cluster_name             = "{{ .Config.ClusterName }}"
   controllers_public_ipv4  = module.packet-{{.Config.ClusterName}}.controllers_public_ipv4
   controllers_private_ipv4 = module.packet-{{.Config.ClusterName}}.controllers_private_ipv4
@@ -258,7 +237,6 @@ output "dns_entries" {
 {{- if eq .Config.DNS.Provider "route53" }}
 provider "aws" {
   version = "2.48.0"
-  alias   = "default"
   # The Route 53 service doesn't need a specific region to operate, however
   # the AWS Terraform provider needs it and the documentation suggests to use
   # "us-east-1": https://docs.aws.amazon.com/general/latest/gr/r53.html.
@@ -272,27 +250,22 @@ provider "ct" {

 provider "local" {
   version = "1.4.0"
-  alias   = "default"
 }

 provider "null" {
   version = "~> 2.1"
-  alias   = "default"
 }

 provider "template" {
   version = "~> 2.1"
-  alias   = "default"
 }

 provider "tls" {
   version = "~> 2.0"
-  alias   = "default"
 }

 provider "packet" {
   version = "~> 2.7.3"
-  alias = "default"

   {{- if .Config.AuthToken }}
   auth_token = "{{.Config.AuthToken}}"
knrt10 commented 4 years ago

Let me try, just a small question, why removed tls, template, and template from required providers?

invidian commented 4 years ago

Let me try, just a small question, why removed tls, template, and template from required providers?

Just a side cleanup, not necessarily part of this task, but something we should do, as those providers are not used in this module.

knrt10 commented 4 years ago

I don't know, still not able to check health. Same error, I applied the same patch

knrt10 commented 4 years ago
My patch ```patch diff --git a/assets/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/require.tf b/assets/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/require.tf new file mode 100644 index 00000000..3ff518e7 --- /dev/null +++ b/assets/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/require.tf @@ -0,0 +1,11 @@ +# Terraform version and plugin versions + +terraform { + required_version = ">= 0.12.0" + + required_providers { + aws = "2.48.0" + ct = "0.5.0" + template = "~> 2.1" + } +} diff --git a/assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/require.tf b/assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/require.tf index 4a4a17bb..b7d840cf 100644 --- a/assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/require.tf +++ b/assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/require.tf @@ -5,9 +5,6 @@ terraform { required_providers { ct = "= 0.5.0" - local = "~> 1.2" - template = "~> 2.1" - tls = "~> 2.0" packet = "~> 2.7.3" } } diff --git a/pkg/assets/generated_assets.go b/pkg/assets/generated_assets.go index 4a35a402..1a0dff4d 100644 --- a/pkg/assets/generated_assets.go +++ b/pkg/assets/generated_assets.go @@ -3568,6 +3568,13 @@ var vfsgenAssets = func() http.FileSystem { compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\xce\xb1\x0e\xc2\x30\x0c\x04\xd0\x3d\x5f\x71\xca\x4e\xff\xa0\x03\x1b\x13\x42\xd0\x3d\x32\x25\x29\x15\x55\x1d\xd9\x0e\x1d\x10\xff\x8e\x4a\x3b\xb0\xb0\x80\x47\xeb\x4e\xf7\xb8\x58\x2e\x06\x6f\x24\x5d\xb4\xd0\x09\x97\x1c\xae\x66\xd9\xe3\xe1\x80\x4b\xd4\x56\xfa\x6c\x3d\x8f\xa8\xe1\xb7\xc7\x3d\x38\x81\xb0\xc4\xf1\x8e\xcf\x9f\x89\xe5\x16\x45\x91\x58\xb0\x6b\x9a\x03\x4c\x28\xa5\xbe\xf5\x0e\xb8\xd3\x50\x22\x96\xab\x41\x93\x86\xe1\x1c\x3e\xf7\xaa\xb5\xbd\x99\x77\x2b\x92\xd1\x3d\x9d\xfb\x0a\xd3\xff\x64\xa7\xdf\x69\xba\xda\x5e\x01\x00\x00\xff\xff\x0e\xbd\x39\x0b\x34\x01\x00\x00"), }, + "/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/require.tf": &vfsgen۰CompressedFileInfo{ + name: "require.tf", + modTime: time.Date(1970, 1, 1, 0, 0, 1, 0, time.UTC), + uncompressedSize: 187, + + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\xcb\xc1\xaa\xc2\x30\x10\x85\xe1\xfd\x3c\xc5\xa1\x77\x1f\xda\x70\x05\x37\xe9\x53\xb8\x97\x60\x46\x09\xb4\x49\x9c\xa4\x75\x21\xf5\xd9\x25\x85\x14\x67\x37\x1f\xff\xf9\xc3\x85\x45\xec\x3d\xca\x8c\x95\x25\xfb\x18\x60\x83\x43\x9a\x96\x87\x0f\x8d\x32\x51\x39\xb2\x37\x01\xc2\xcf\xc5\x0b\xbb\x6b\xdb\x18\x74\xa3\x41\xaf\x06\xad\xfa\x8e\x7e\x8b\x24\x71\xf5\x8e\x25\xef\x43\xc0\xbe\x32\xf6\x33\xe8\xb4\xfa\x3f\xd7\xbe\xbe\xb7\x82\xc3\x7b\x75\x6a\x5c\x78\x4e\x93\x2d\x5c\xf9\x33\x42\xab\xa1\xfa\x46\x1b\x7d\x03\x00\x00\xff\xff\x82\x99\x9d\xf0\xbb\x00\x00\x00"), + }, "/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/variables.tf": &vfsgen۰CompressedFileInfo{ name: "variables.tf", modTime: time.Date(1970, 1, 1, 0, 0, 1, 0, time.UTC), @@ -5023,9 +5030,9 @@ var vfsgenAssets = func() http.FileSystem { "/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/require.tf": &vfsgen۰CompressedFileInfo{ name: "require.tf", modTime: time.Date(1970, 1, 1, 0, 0, 1, 0, time.UTC), - uncompressedSize: 239, + uncompressedSize: 167, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x8c\x31\xae\x83\x30\x10\x44\xfb\x3d\xc5\x88\xdf\x5b\xc0\x57\x94\x0a\x4e\x91\x3e\xb2\x60\x13\x59\x31\xd8\x59\x1b\x9a\x88\x9c\x3d\x32\x18\xc4\x76\xfb\x66\xde\xfc\xe1\xc6\x22\xfa\xe1\x64\xc0\xcc\x12\x8c\x1b\xa1\xc7\x1e\xde\x4e\x4f\x33\xee\x28\x10\xc5\xa3\xf6\x21\x40\xf8\x3d\x19\xe1\xfe\xbe\x3b\x0d\x8a\xb6\x41\xa9\xaa\x5a\x95\x05\x9d\x1b\x5e\xdc\x6c\x7a\x96\xb0\x8a\x40\x17\xb1\x5d\x83\x22\x19\x97\x24\xa4\xdf\xba\x4e\xdb\x1c\x7c\x5b\x54\xaa\xde\x78\xe4\xc1\x5b\x1d\x39\xf3\x5a\x55\x99\xdb\x70\x0c\xad\x3c\xef\x78\xdd\xbd\x38\x9e\xf8\x55\xfd\xa7\x64\xa1\x85\x7e\x01\x00\x00\xff\xff\x3a\xca\x17\x48\xef\x00\x00\x00"), + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\xcb\xc1\x0e\xc2\x20\x10\x04\xd0\xfb\x7e\xc5\x04\xef\xa4\xd6\x18\x4f\xf4\x2b\xbc\x1b\x52\x56\x43\x54\xc0\x85\xf6\x62\xea\xb7\x1b\x6c\x30\xdd\xdb\xce\xcc\xdb\xe1\xcc\x22\xf6\x1a\xe5\x89\x99\x25\xfb\x18\x60\x83\x43\x7a\x4c\x37\x1f\x5a\x94\x89\xca\x7f\xf6\x26\x40\xf8\x35\x79\x61\x77\x69\xc6\x40\x0d\x06\x9d\xde\xf7\xba\x53\xb4\x5d\x24\x89\xb3\x77\x2c\xf9\x07\x81\xb1\x60\x3d\x03\x55\xc5\xb1\x82\xfa\x27\x3b\xde\xb9\xac\xc5\x67\x40\xaf\x4f\xfa\x50\x9b\x85\x16\xfa\x06\x00\x00\xff\xff\x0e\xa9\x96\xd4\xa7\x00\x00\x00"), }, "/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/variables.tf": &vfsgen۰CompressedFileInfo{ name: "variables.tf", @@ -5736,6 +5743,7 @@ var vfsgenAssets = func() http.FileSystem { fs["/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/cl"].(os.FileInfo), fs["/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/ingress.tf"].(os.FileInfo), fs["/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/outputs.tf"].(os.FileInfo), + fs["/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/require.tf"].(os.FileInfo), fs["/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/variables.tf"].(os.FileInfo), fs["/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers/workers.tf"].(os.FileInfo), } diff --git a/pkg/platform/aws/template.go b/pkg/platform/aws/template.go index 2e59d25d..4246e596 100644 --- a/pkg/platform/aws/template.go +++ b/pkg/platform/aws/template.go @@ -18,14 +18,6 @@ var terraformConfigTmpl = ` module "aws-{{.Config.ClusterName}}" { source = "../lokomotive-kubernetes/aws/flatcar-linux/kubernetes" - providers = { - aws = aws.default - local = local.default - null = null.default - template = template.default - tls = tls.default - } - cluster_name = "{{.Config.ClusterName}}" tags = {{.Tags}} dns_zone = "{{.Config.DNSZone}}" @@ -109,10 +101,6 @@ module "aws-{{.Config.ClusterName}}" { module "worker-pool-{{ $index }}" { source = "../lokomotive-kubernetes/aws/flatcar-linux/kubernetes/workers" - providers = { - aws = aws.default - } - vpc_id = module.aws-{{ $.Config.ClusterName }}.vpc_id subnet_ids = flatten([module.aws-{{ $.Config.ClusterName }}.subnet_ids]) security_groups = module.aws-{{ $.Config.ClusterName }}.worker_security_groups @@ -183,7 +171,6 @@ module "worker-pool-{{ $index }}" { provider "aws" { version = "2.48.0" - alias = "default" region = "{{.Config.Region}}" {{- if .Config.CredsPath }} @@ -197,22 +184,18 @@ provider "ct" { provider "local" { version = "1.4.0" - alias = "default" } provider "null" { version = "~> 2.1" - alias = "default" } provider "template" { version = "~> 2.1" - alias = "default" } provider "tls" { version = "~> 2.0" - alias = "default" } # Stub output, which indicates, that Terraform run at least once. diff --git a/pkg/platform/packet/template.go b/pkg/platform/packet/template.go index d4da1ad0..ff2a4315 100644 --- a/pkg/platform/packet/template.go +++ b/pkg/platform/packet/template.go @@ -18,14 +18,6 @@ var terraformConfigTmpl = ` module "packet-{{.Config.ClusterName}}" { source = "../lokomotive-kubernetes/packet/flatcar-linux/kubernetes" - providers = { - local = local.default - null = null.default - template = template.default - tls = tls.default - packet = packet.default - } - dns_zone = "{{.Config.DNS.Zone}}" ssh_keys = {{.SSHPublicKeys}} @@ -124,13 +116,6 @@ EOF module "worker-{{ $pool.Name }}" { source = "../lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers" - providers = { - local = local.default - template = template.default - tls = tls.default - packet = packet.default - } - dns_zone = "{{$.Config.DNS.Zone}}" ssh_keys = {{$.SSHPublicKeys}} @@ -236,12 +221,6 @@ EOF module "dns" { source = "../lokomotive-kubernetes/dns/{{.Config.DNS.Provider}}" - {{ if eq .Config.DNS.Provider "route53" -}} - providers = { - aws = aws.default - } - - {{ end -}} cluster_name = "{{ .Config.ClusterName }}" controllers_public_ipv4 = module.packet-{{.Config.ClusterName}}.controllers_public_ipv4 controllers_private_ipv4 = module.packet-{{.Config.ClusterName}}.controllers_private_ipv4 @@ -258,7 +237,6 @@ output "dns_entries" { {{- if eq .Config.DNS.Provider "route53" }} provider "aws" { version = "2.48.0" - alias = "default" # The Route 53 service doesn't need a specific region to operate, however # the AWS Terraform provider needs it and the documentation suggests to use # "us-east-1": https://docs.aws.amazon.com/general/latest/gr/r53.html. @@ -272,27 +250,22 @@ provider "ct" { provider "local" { version = "1.4.0" - alias = "default" } provider "null" { version = "~> 2.1" - alias = "default" } provider "template" { version = "~> 2.1" - alias = "default" } provider "tls" { version = "~> 2.0" - alias = "default" } provider "packet" { version = "~> 2.7.3" - alias = "default" {{- if .Config.AuthToken }} auth_token = "{{.Config.AuthToken}}" ```
invidian commented 4 years ago

To be able to upgrade from this patch, I did the following:

sed -i 's/provider.template.default/provider.template/g' lokomotive-assets/terraform/terraform.tfstate
sed -i 's/provider.aws.default/provider.aws/g' lokomotive-assets/terraform/terraform.tfstate

Though I am not sure if this is the right approach :smile: