-
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
Provider configuration not passed to grandchild modules #2832
Comments
@ryanuber, just tried to reproduce this against 5194eb4, with the following configuration: main.tfprovider "aws" {
region = "us-east-1"
}
module "foo" {
source = "./foo"
} foo/main.tfmodule "bar" {
source = "./bar"
} foo/bar/main.tfresource "aws_vpc" "baz" {
cidr_block = "10.0.0.0/16"
} I'm getting mixed results, similarly to yours. Destroy in particular seems to want credentials each time. Definitely seems like there's an issue somewhere here, I'll investigate further. |
There's something else at play here as well. I removed my "middle" module to work around this bug, and this is happening: With Terraform 0.6.6:
Above succeeds if I remove the
It looks like no top-level variables are being passed down - output shows a failure in a provider, a module, and a plain resource. |
For the provider level variables I have used a workaround to get this going for the time being. I set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION environment variables and then run terraform and the provider specific vars get passed through. Not a fix but a good workaround to date. |
For the record, |
@arohter's solution works well when creating new resources, however if you later remove a module from your configuration and run In my case the AWS environment variable fix doesn't work. I'm using S3 remote states using buckets in a different AWS account than the one I'm applying against (remote state uses the default AWS creds). When the provider is "lost" it falls back to the default (environment variable or the
Also this is intermittent... the provider is lost only some of the time. I'm not real familiar with how the Terraform state tree works, but this feels like a race condition. It's as if the provider is a global reference and is set and lost as the apply routine is traversing the tree. |
I'm still experiencing this issue on terraform 0.8.6. Is anyone else having the same problem? |
I seem to still be having this issue on 0.11.8 |
For people that seems to face this : I was using both named profiles and environment variables. The latter are used before the profiles causing the confusion. |
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. |
When calling a module from another module, provider configuration does not seem to be propagated all the way down to the grandchild. This works as expected with a single level of modules, but when 2 or more layers are involved, the issue rears its head.
Terraform v0.6.2-dev (5a15c02)
main.tf
foo/main.tf
foo/bar/main.tf
Result:
The other weird thing is that the error is not always the same. I've seen 3 (!) different outputs for the same input. The others include an interactive prompt for the credentials:
Or an invalid token error, which I would expect for this example:
The text was updated successfully, but these errors were encountered: