Closed steeef closed 3 years ago
I managed to solve my own issue:
I changed the providers block to:
providers = {
aws = aws.dev_va
aws.apex = aws.master_va
}
Apparently this is required when passing providers with aliases. In general, you have to list <type>.<alias>
to get Terraform to recognize it properly.
If there's a better way to do this (like using required_providers
in the module's terraform
configuration block), let me know. I didn't see any explicit documentation on this in either the existing reference documentation or the "Upgrading to Terraform 0.13" page.
Hi @steeef! I just wanted to note here some more of what we talked about in chat earlier:
It seems like this would've been much clearer had Terraform been able to recognize that:
apex
defined or implied by this module.aws.apex
in there.That seems like a strong enough heuristic for the error message to potentially include "Did you mean aws.apex
?" as a hint for how to address it.
Since Terraform was working as designed here but there is an opportunity for improving the error message, I'm going to relabel this as an enhancement.
The Passing Providers Explicitly section in the docs includes an example of passing aliased providers between modules:
module "tunnel" {
source = "./tunnel"
providers = {
aws.src = aws.usw1
aws.dst = aws.usw2
}
}
While working on this, we can also consider if there's a better place to document this that would be more discoverable, though we must trade that against the fact that this sort of pattern is relatively unusual (compared to other patterns around passing providers) and so we likely wouldn't want to make it so prominent that it overwhelms other information that'd be more relevant.
Sounds fair. I appreciate your help!
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.
Terraform Version
Terraform Configuration Files
versions.tf
:main.tf
:modules/organization_route53/main.tf
:Debug Output
https://gist.github.com/steeef/6a432c498862ef3ded498522b23a3c75
Crash Output
Expected Behavior
Terraform should use the default
aws
provider to create an AWS Route 53 zone, and then the provider with aliasapex
to create the DNS records to delegate entries for the subdomain in theaws
provider.Actual Behavior
I recieved the error:
Steps to Reproduce
Additional Context
I'm upgrading an existing Terraform configuration from
v0.12.29
tov0.13.3
. This is a complicated configuration since it manages an entire AWS Organizations organization including AWS account-specific resources in multiple accounts. The intent here is to manage AWS Route53 zones for both themaster
account (referenced by the provider with aliasapex
) and any member accounts (referenced by the defaultaws
provider). Each account in the AWS Organization has a copy of theroute53
module, including themaster
account, where both providers (aws
andapex
) point to the samemaster_va
provider. I can't determine from the error message which one of these entries caused the error. I can paste more if necessary.I find it odd that it's trying to find a provider with type
apex
when it's really a provider with typeaws
and aliasapex
.References