I’m attempting to use the new ‘import’ block to import a manually created Route53 zone in AWS into my Terraform state.
I have a number of environments in which I’m running my TF deploy and this import block is only relevant for the ‘production’ environment. I therefore need to make this import block conditional.
I’ve attempted to do so using the ‘count’ and a local var to read my ‘environment’ variable:
locals {
prod-env = var.environment == "prod"
}
import {
count = local.prod-env ? 1 : 0
to = aws_route53_zone.example
id = "myhostedzoneid"
}
resource "aws_route_53_zone" "example" {
count = local.prod-env ? 1 : 0
name = "example.com"
}
However, when I run a plan using this configuration I get the following error:
╷
│ Error: Unsupported argument
│
│ on hosted_zone.tf line 6, in import:
│ 6: count = local.prod-env ? 1 : 0
│
│ An argument named "count" is not expected here.
Any better way to do this?