_This issue was originally opened by @Craigfis as hashicorp/terraform#23517. It was migrated here as a result of the provider split. The original body of the issue is below._
I'm using Terraform version 12.16 and trying to run terraform apply to update a deployment.
Terraform v0.12.16
+ provider.aws v2.20.0
provider "aws" {
version = "~> 2.17"
region = "us-west-2"
}
...
Unable to share.
Should succeeed.
Error
terraform initterraform applyhttps://github.com/terraform-providers/terraform-provider-aws/issues/9989
Seeing the same thing here, apply is successful but it output the error everytime on the first run:
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_iam_role_policy_attachment.prod_usw2_prod1_nomad_compute_to_prod1_nomad_compute_efs_kms: Destroying... [id=prod-usw2-prod1-nomad-compute-efs-20190827185557742400000003]
aws_efs_file_system.prod1_nomad_compute_efs: Modifying... [id=fs-5b1642f0]
aws_iam_role_policy_attachment.prod_usw2_prod1_nomad_compute_to_prod1_nomad_compute_efs_kms: Destruction complete after 1s
aws_iam_policy.prod1_nomad_compute_efs_kms: Destroying... [id=arn:aws:iam::087700185875:policy/prod1_nomad_compute_efs_kms]
aws_iam_role.prod_usw2_prod1_nomad_compute_efs: Destroying... [id=prod-usw2-prod1-nomad-compute-efs]
aws_efs_file_system.prod1_nomad_compute_efs: Modifications complete after 1s [id=fs-5b1642f0]
aws_iam_policy.prod1_nomad_compute_efs_kms: Destruction complete after 1s
aws_iam_role.prod_usw2_prod1_nomad_compute_efs: Destruction complete after 1s
Error: Missing required argument
The argument "region" is required, but was not set.
If I run the same apply again, no changes (and the outputs will show up):
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
I'm seeing the same error on the first terraform apply after a terraform init. Are there any updates on this?
I have the same issue.
terraform 0.12.18
terraform-provider-aws_v2.41.0_x4
Here's an example. Running "terraform apply" on the configuration below will create the two EIPs.
provider "aws" {
region = "us-east-1"
alias = "prodalias"
}
resource "aws_eip" "eip_a" {
vpc = true
provider = aws.prodalias
}
resource "aws_eip" "eip_b" {
vpc = true
provider = aws.prodalias
}
However, if you now update your code and "remove" a resource as depicted below...
provider "aws" {
region = "us-east-1"
alias = "prodalias"
}
resource "aws_eip" "eip_a" {
vpc = true
provider = aws.prodalias
}
# resource "aws_eip" "eip_b" {
# vpc = true
# provider = aws.prodalias
# }
...and run "terraform apply" again, you get the following error message:
...
aws_eip.eip_b: Destroying... [id=eipalloc-0f208a2bcd35ed8c7]
aws_eip.eip_b: Destruction complete after 0s
Error: Missing required argument
The argument "region" is required, but was not set.
Note, eip_b did get successfully destroyed, and running "terraform apply" again after this error message will indicate no changes and exit cleanly.
Hi everyone 👋 Thank you for reporting this and sorry you are running into this unexpected behavior.
The output provided by @scalp42 and reproduction provided by @jjsp556 above does seem to highlight some sort of bug within the Terraform CLI where its performing region validation for the "default" provider, even though only aliased provider resources are in use. I have submitted the following upstream to track that issue: https://github.com/hashicorp/terraform/issues/23671
Since there is likely nothing to change or fix in the Terraform AWS Provider for this specific case, I'm going to close this issue in preference of the upstream issue. If you are still having unrelated trouble with the The argument "region" is required, but was not set. error, and https://github.com/terraform-providers/terraform-provider-aws/issues/9989#issuecomment-557634793 does not provide any guidance, please submit a fresh new bug report filling out the issue template details and we will take another look.
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!