-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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 tells me The argument "region" is required, but was not set. #9989
Comments
Are you running this from your local machine? I get the same exact error when I run terraform plan through Jenkins but it works fine locally with the same terraform version. |
I'm running terragrunt/terraform on my local machine. |
Getting the same error in our pipelines.
|
I faced similar issue. My problem was that I used |
That is it exactly. I ran an apply with TF_LOG=TRACE and found where there was a provider.aws that errorred and what resource that was attached to.
I had updated that module at one point and removed module.app-cluster.module.asg.aws_autoscaling_group.b and instead made module.app-cluster.module.asg.aws_autoscaling_group.a more flexible now that terraform 0.12 can do cool things like |
I had this issue, but when I killed the stack, nuked the state file and then re-built the stack, everything was fine. Has something to do with the state file, I think. |
This is related to hashicorp/terraform#21313 and should be fixed by hashicorp/terraform#22811 |
I'm running into the same issue whenever I execute
Any suggestions? I thought this was fixed. |
@neysofu Another reason that can happen with a new project is that you don't have the aws provider configured. Try configuring in |
OP posted their provider code and it lgtm |
Not sure if this is fixed on newer versions, but the temporary solution that works for me is:
|
Still have this problem with 0.12.13. Workaround of @jonathortense checks out. |
I was facing the same issue for the region even after providing the default region = "us-east-1" in vars.tf. What fixed this issue was I re-ran terraform apply with my sso profile (OKTA) as it has the region set as |
still happening in 0.12.16 :( ...and manually removing offending module from state still fixes the problem. 👍 |
For me this seems to be hashicorp/terraform/21313 as my state file was full of resources with empty instance arrays after I did a destroy of the entire environment. I have a lot of optional building in my config where I'll generate count = length(variable) instances, and that may well be 0. |
Hi folks 👋 Sorry for this frustrating behavior and thank you for reporting it here. It appears this issue report may be diverging due to several consequences for this type of error message. One important piece to note is that all Terraform configuration that references any Terraform AWS Provider resource or data source must include some form of a region configuration. This can be either configured in the form of an environment variable such as provider "aws" {
region = "us-east-1"
} This is true even for a Terraform configuration that does not physically use any AWS APIs, such as those using the Another cause for this type of issue is the Terraform CLI logic, when calling Our best recommendation here will be try upgrading your Terraform CLI version to 0.12.11 or later (0.12.16 is most recent as of this writing) and trying again. If you are still having trouble after then, we would suggest opening a bug report upstream at https://github.com/hashicorp/terraform/issues/new?template=bug_report.md, filling out the requested details in the issue template so that team can triage further. If your issue really does appear to be an issue within the Terraform AWS Provider initialization when it tries to determine the region based on the provider configuration, AWS shared configuration files, or environment variable, then filing a new bug report in this repository would be appropriate and we can take a fresh look for your situation. My apologies if this answer does not seem sufficient in this case as these issues that straddle between the two codebases are sometimes misdiagnosed and hopefully either upgrading the Terraform CLI or future potential bug fixes based off fresh reports can help narrow this down better. Thank you! |
I was facing the same issue in TF Cloud, Adding |
@bflad Exactly, faced the issue you mentioned while using 0.12.6 and fixed by passing provider |
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! |
Community Note
Terraform Version
Terraform v0.12.7
Affected Resource(s)
unknown
Terraform Configuration Files
....
Debug Output
https://gist.github.com/grimm26/41ab564a415361bfe6dfb3a6ce1b3a47
Expected Behavior
Work without complaining.
Actual Behavior
worked? but also:
Error: Missing required argument
The argument "region" is required, but was not set.
Steps to Reproduce
terraform apply
sometimes it happens, sometimes it does not. My providers are always defined with a region and a profile. FYI, the profile is an assumed role and I have
AWS_SDK_LOAD_CONFIG=1
set.Important Factoids
My providers are always defined with a region and a profile. FYI, the profile is an assumed role and I have
AWS_SDK_LOAD_CONFIG=1
set.References
The text was updated successfully, but these errors were encountered: