I need to make an AWS certificate reside in a different region, and the docs say that I can use an aliased provider.
I’ve added the alias provider after the main one:
provider "aws" {
region = "eu-central-1"
}
provider "aws" {
alias = "us-east-1"
region = "us-east-1"
}
And added it to the resource:
resource "aws_acm_certificate" "cert" {
...
provider = aws.us-east-1
...
}
and when I try to terraform apply
or even terraform validate
I get this error:
Error: Provider configuration not present
To work with aws_acm_certificate.cert its original provider configuration at
provider.aws.us-east-1 is required, but it has been removed. This occurs when
a provider configuration is removed while objects created by that provider
still exist in the state. Re-add the provider configuration to destroy
aws_acm_certificate.cert, after which you can remove the provider
configuration again.
This doesn’t make any sense since terraform state list
returns nothing, as I have no resource created.
I don’t understand what I’m doing wrong. Most people I see having this issue are using the different provider from within a module, however, I am not. I’m defining this resource in the main module, same level where the alias provider is defined.
Any recommendations?
Hi @madpipeline!
I’m not sure what’s going on here either. As you noted, this error most commonly appears when a provider configuration is used in a child module and should appear only when the resource instance in question is already created and recorded in the state. It’s very strange to see this error message talking about an object that isn’t created yet at all.
I’d like to try to recreate this to understand better what’s going on. Could you share your output from terraform version
(so I can make sure I match the same Terraform CLI and provider versions) and, if possible, a minimal-but-functional standaloneresource "aws_acm_certificate"
block raises this error this problem for you? Thanks!
My infrastructure WIP is here: https://github.com/Utwo/date-la-zi/tree/deploy-s3/aws_deploy
Files of interest are main.tf
and dns.tf
.
My terraform version is v0.12.23
.
I’ve found my issue. I was just being stupid. I added the provider in a different deploy by mistake.
Thanks for sharing the additional details anyway @madpipeline, and I’m glad you figured it out!
I was getting the same error when trying to pass provider aliases to a module. My issue was that I hadn’t defined the providers within the module, so it didn’t know to expect them.
The error message for undefined variables is nice and clear, but this one for undefined providers is pretty misleading.