-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Error message without context when validating provider configuration #28482
Comments
Hi @gtmtech, thanks for reporting this. I'm able to reproduce the issue. I spent some time looking into how we might improve this today, and I haven't come to any solid conclusions. The source of the diagnostic you're seeing is here: terraform/terraform/node_provider.go Lines 108 to 112 in 4b1ff4e
At this point, Terraform is evaluating the provider configuration for an implied provider. In this case, the configuration is missing (as there is no Given the language design constraints described in #28483, it's not clear to me what useful error message we could return here. The best I'm able to propose is that we check for a
This would at least tell you which provider has missing configuration, but I don't know how helpful that is. Ideally we'd be able to point to which resource(s) caused this provider to be required, but it's not clear to me how we might be able to do that without significant refactoring. |
Hi @alisdair - using another account to comment as its hitting me again. Yeah, my problem is I dont use default providers, because I want to be specific about all resources, and I dont want regional resources being accidentally created in the wrong region (e.g. s3 buckets) as its a pain to unpick and transfer region. So I make sure AWS_DEFAULT_REGION Is unset, and I also make sure that there is no default region in ~/.aws/config - that way, if a resource has no "provider", then it will use the implied provider, and then bomb out with this message. Sadly though, diagnosing on which resource is the missing provider attribute is extremely hard. I have found out that it could be in any of the resources, datasources, or even in none of them, and in a statefile resource which has been deleted in local codebase where is the culprit with the lack of provider definition. What I would really like to see is the resource which is causing the error, either in the statefile or in the local codebase. E.g.
That last line would be sooooo helpful, without it, I have to intelligently scan all my codebase plus the remote statefile and parse it manually to see where I might be missing a provider. I raised a separate issue I believe saying cant we abandon the default provider and be nice and specific (defaults are generally ALWAYS an antipattern if you ask me, because they represent catchalls where a human has not been specific enough, but lead to sometimes unintentional (by virtue that the human coder has not specified exactly what should happen) and very difficult to resolve situations if you do multiregion or multi-iam stuff with your providers like I do). However I think @jbardin and @apparentlymart said on #28483 that wouldn't be removed as everyone uses it. Removing the default region is the only way I've found to force my codebase to catch the examples where I havent set an explicit provider, but unfortunately the error message makes it extremely hard to track down the resource in question. |
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. |
Terraform Version 0.15.0
I spent hours trying to track down an error because the error had no context as to what resource it related to. In this case, it was because I only had aliased providers (deliberately, I dont like "default" providers when doing multi-region terraforming because it can lead to errors creating resources in the wrong place). In my codebase I had a single resource (a data source of aws_caller_identity) defined, amongst 1000s of resources. There was rightly an error - but I had to individually take out files until I understood what the error was - a much more useful error message should be had here.
In addition, there is (in my view) a far more serious bug.... I defined no aws default provider , yet terraform made its own up. IE - in the example below, if AWS_DEFAULT_REGION is set to us-east-1 then the command works. This has no right to work if there is no generic aws provider set.
However this bug is actually about the error message - imagine seeing
The argument "region" is required, but was not set
and having no idea where in your huge codebase it is talking about. - ThanksTerraform Configuration Files
Additional Context
Before running, make sure AWS_DEFAULT_REGION is unset.
Expected Behavior
I expected any error messages about the above to be more useful
Actual Behavior
Error message was:
The difficulty with this error message was that plenty of resources may have a region attribute - and same with providers - I had no idea to which resource or provider it was referring.
Steps to Reproduce
Just the above
The text was updated successfully, but these errors were encountered: