Terraform v0.11.8
+ provider.aws v1.42.0
Your version of Terraform is out of date! The latest version
is 0.11.10. You can update by downloading from www.terraform.io/downloads.html
#############
# DNS Zones #
#############
resource "aws_route53_zone" "dns_zone" {
name = "${element(local.delegated_zones, count.index)}"
// vpc_id = "${count.index == length(local.delegated_zones) - 1 ? var.vpc_id : ""}" // this is still required! Even though it is depreciated
vpc { // new syntax
vpc_id = "${count.index == length(local.delegated_zones) - 1 ? var.vpc_id : ""}"
}
count = "${length(local.delegated_zones)}"
}
Should accept vpc {} block in favour of vpc_id
I get deprecation warnings when using vpc_id and when I use new filter method:
Warning: module.kubernetes.aws_route53_zone.dns_zone[0]: "vpc_id": [DEPRECATED] use 'vpc' attribute instead
Warning: module.kubernetes.aws_route53_zone.dns_zone[1]: "vpc_id": [DEPRECATED] use 'vpc' attribute instead
Warning: module.kubernetes.aws_route53_zone.dns_zone[2]: "vpc_id": [DEPRECATED] use 'vpc' attribute instead
Error: Error running plan: 2 error(s) occurred:
* module.kubernetes.aws_route53_zone.dns_zone[1]: vpc.0.vpc_id must not be empty
* module.kubernetes.aws_route53_zone.dns_zone[0]: vpc.0.vpc_id must not be empty
terraform planAs far as I am aware old method of defining data source still works
https://github.com/terraform-providers/terraform-provider-aws/blob/master/CHANGELOG.md
resource/aws_route53_zone: The vpc_id and vpc_region arguments have been deprecated in favor of vpc configuration block(s). To upgrade, wrap existing vpc_id and vpc_region arguments with vpc { ... }. Since vpc is an exclusive set of VPC associations, you may need to define other vpc configuration blocks to match the infrastructure, or use lifecycle configuration ignore_changes to suppress the plan difference.
replacing vpc_id with vpc doesn't do it either, it.
invalid or unknown key: vpc
I would think you could do something like this
resource "aws_route53_zone" "dns_zone" {
name = "${element(local.delegated_zones, count.index)}"
vpc = ["${count.index == length(local.delegated_zones) - 1 ? list(map("vpc_id", var.vpc_id)) : list()}"]
count = "${length(local.delegated_zones)}"
}
but when I tried it I got this error.
Error: aws_route53_zone.dns_zone[2]: "vpc.0.vpc_id": required field is not set
(Note: the error and syntax in the HCL snippet above is not _exactly_ what I tried, since I don't have your exact TF)
Maybe something like this, but more correct, might do the trick.
Hey, thanks for getting back to me - definitely think this is a bug in Terraform. From the change log snippet above the format should be something like:
resource "aws_route53_record" "some_record" {
vpc {
vpc_id = "<SOME_ID>"
}
}
But Terraform complains about missing vpc_id key in top level of the resource like you describe. If you add the vpc_id key and omit the the vpc {} block you get deprecation warnings but it does work. Sounds like a HCL validation issue in the TF provider. Note above code is illustrative only!
Hi, I'm having the same issue with the following syntax:
resource "aws_route53_zone" "private_zone_com_ar" {
name = "<domain>.com.ar."
vpc = ["${module.vpc.vpc_id}"]
tags {
Environment = "${var.environment}"
Terraform = "True"
Tenant = "Public"
}
}
Experiencing the issue with the below versions
Terraform v0.11.10
I am experiencing the same issue:
Terraform v0.11.11
it worked for me with:
As @avoidik mentioned, I too tried it with 1.56.0 and I'm not seeing the warning anymore. Maybe this commit fixed it?
Hi folks 馃憢 Given the comments above, it appears this may have been resolved a few months ago. The old logic with vpc_id is no longer present in the Terraform AWS Provider since version 2.0.0 (#7695). Since the maintainers will not prioritize any fixes to the old major version at this point in time, I'm going to close this issue to help clean up the open issues to only those actionable.