Terraform-provider-aws: VPC ID still required even though it is deprecated - aws_route53_zone

Created on 5 Nov 2018  路  9Comments  路  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

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

Affected Resource(s)

  • aws_route53_zone

Terraform Configuration Files

#############
# 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)}"
}

Expected Behavior

Should accept vpc {} block in favour of vpc_id

Actual Behavior

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

Steps to Reproduce

  1. terraform plan

Important Factoids

As far as I am aware old method of defining data source still works

References

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.

servicroute53

All 9 comments

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

  • provider.aws v1.42.0
  • provider.random v2.0.0
  • provider.template v1.0.0

I am experiencing the same issue:

Terraform v0.11.11

  • provider.aws v1.54.0

it worked for me with:

  • provider.aws v1.56.0

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.

Was this page helpful?
0 / 5 - 0 ratings