-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform should warn when unexpected attributes are in required_providers #26160
Comments
For comparison, the following produces the expected result. Same AWS profile configuration and env is in effect here. Terraform Version
Terraform Configuration Filesprovider "aws" {
version = "3.5.0"
profile = "terraform"
region = "us-east-1"
}
terraform {
backend "s3" {
profile = "terraform"
region = "us-east-1"
bucket = "terraform-francisferrell"
key = "terraform.tfstate"
dynamodb_table = "terraform-francisferrell"
}
}
resource "aws_s3_bucket" "foo" {
} |
hi @francisferrell ! The required_providers setting is only used to set the version and source for a provider - you still need your provider configuration block: terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.5.0"
}
}
provider "aws" {
profile = "terraform"
region = "us-east-1"
}
backend "s3" {
profile = "terraform"
region = "us-east-1"
bucket = "terraform-francisferrell"
key = "terraform.tfstate"
dynamodb_table = "terraform-francisferrell"
}
}
resource "aws_s3_bucket" "foo" {
} When I originally wrote this, I omitted any error message for unexpected attributes in a required_providers setting (like "region" in your first example) for backwards compatibility (0.12 accepted the new required_providers syntax but ignored anything other than "version"), but if this confusion comes up frequently we can change that. I am going to re-title and re-label this as an enhancement, specifically to add a warning when unexpected attributes show up in |
@mildwonkey got it, thanks for clarifying. I'll give it a try tonight and verify that it works like expected. I think I was confused by the way the docs present it (https://registry.terraform.io/providers/hashicorp/aws/latest/docs). In the docs for the aws provider, when I click on the USE PROVIDER button and get the popup, the two forms are presented in a way that seems mutually exclusive: Terraform 0.13 [Latest] terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.5.0"
}
}
} vs: Terraform <= 0.12 provider "aws" {
version = "3.5.0"
} Then, in the body of that document, right at the top, is this example: # Configure the AWS Provider
provider "aws" {
version = "~> 3.0"
region = "us-east-1"
} Not knowing better, I interpret this as a holdover from 0.12.x that hasn't yet been updated for the new 0.13.x syntax, so I dutifully migrate the entire provider section into the aws section inside required_providers. Maybe there's some other documentation somewhere else that explains how providers in general are configured and how 0.13 introduces a split of the provider version into a separate block form the provider's own parameters. But, looking at https://www.terraform.io/docs/backends/config.html and https://www.terraform.io/docs/providers/index.html there are no mentions of required_providers in either. |
@mildwonkey as written this gives:
I put That got my issue sorted out. I got a complete plan/apply/destroy cycle working as expected with no prompts for region. Thanks for pointing me in the right direction. Here's the full tf for reference terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.5.0"
}
}
backend "s3" {
profile = "terraform"
region = "us-east-1"
bucket = "terraform-francisferrell"
key = "terraform.tfstate"
dynamodb_table = "terraform-francisferrell"
}
}
provider "aws" {
profile = "terraform"
region = "us-east-1"
}
resource "aws_s3_bucket" "foo" {
} |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
I'm just getting spun up with vanilla terraform for a personal project after using terragrunt at work. I think I've got it configured correctly, but maybe I made a mistake. I think this is a bug in terraform, not in the aws provider, because a trivial sample works on 0.12.29 but the behavior regresses on 0.13.2.
I have the region configured in the tf and as the region in the AWS profile config. I therefore expect to not be prompted for the region.
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
A plan
Actual Behavior
Steps to Reproduce
terraform init
terraform plan
Additional Context
References
The text was updated successfully, but these errors were encountered: