Currently, because of providers defined at the module level, you cannot delete the module to remove your infrastructure. Conversely, you have to use commands to remove items from the state file before you can delete. See #108
Per these 2 issues, it seems after terraform 0.11 these providers should no longer be in modules.
https://github.com/hashicorp/terraform/issues/16824
https://github.com/hashicorp/terraform/issues/17928
User Terraform > 0.11 and add the module to create infra, after the apply remove the code, you will get error.
All infra in this module is deleted.
Yes, but don't have permissions to contribute. eg create branch for a PR.
Something like this should fix the issues, I tested locally and it works on my machine.
provider "null" {
version = "~> 1.0"
alias = "default"
}
provider "template" {
version = "~> 1.0"
alias = "default"
}
module "eks" {
source = terraform-aws-modules/eks/aws"
cluster_name = "development"
subnets = "${module.vpc_app.private_subnets}"
tags = "${map("Environment", "${var.stage}")}"
vpc_id = "${module.vpc_app.vpc_id}"
manage_aws_auth = false
providers = {
aws = "aws.default"
null = "null.default"
template = "template.default"
}
}
Next __remove__ these lines from main.tf
...
- provider "null" {}
- provider "template" {}
Is this really standard practice now? We need to pass providers into every module?
Is this really standard practice now? We need to pass providers into every module?
No.
The primary provider instance does not need an alias specified. You only need to use alias if you are dealing with multiple instances of the same provider (e.g. default aws provider is in us-east-1 and you also want to add DR resources in us-west-2).
provider "aws" {
region = "us-east-1"
}
provider "aws" {
region = "us-east-2"
alias = "dr"
}
The default provider is automatically passed through to modules for their use.
Setting version on providers is not required but is recommended best practice.
It is recommended best practice not to define providers within modules. It is really frustrating from a module provider's PoV as you cannot specify the minimum compatible provider version. This has caused confusion in the community VPC module a few times when e.g. the new tags-on-EIPs feature was used.
Removing null and template should not be a breaking change. Users will get a warning that they should add a provider block with version when doing terraform init
Chris's example is better written as:
provider "null" {
version = "~> 1.0"
}
provider "template" {
version = "~> 1.0"
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
cluster_name = "development"
subnets = "${module.vpc_app.private_subnets}"
tags = "${map("Environment", "${var.stage}")}"
vpc_id = "${module.vpc_app.vpc_id}"
manage_aws_auth = false
}
Removing null and template should not be a breaking change.
Alright, let's do that now. I'll make a PR.
How does this look? https://github.com/terraform-aws-modules/terraform-aws-eks/pull/168
PR is now merged so I'll close this issue.
Most helpful comment
No.
The primary provider instance does not need an
aliasspecified. You only need to usealiasif you are dealing with multiple instances of the same provider (e.g. default aws provider is inus-east-1and you also want to add DR resources inus-west-2).The default provider is automatically passed through to modules for their use.
Setting
versionon providers is not required but is recommended best practice.It is recommended best practice not to define providers within modules. It is really frustrating from a module provider's PoV as you cannot specify the minimum compatible provider version. This has caused confusion in the community VPC module a few times when e.g. the new tags-on-EIPs feature was used.
Removing
nullandtemplateshould not be a breaking change. Users will get a warning that they should add a provider block with version when doingterraform initChris's example is better written as: