Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vpc region in route 53 zone association #5736

Conversation

yuan-stripe
Copy link

@yuan-stripe yuan-stripe commented Aug 30, 2018

Changes proposed in this pull request:

  • Update vpc region in route 53 zone association

Output from acceptance testing (too afraid to run on our internal infrastructure)

All unit tests passed though:

$ make test
==> Checking that code complies with gofmt requirements...
go test ./... -timeout=30s -parallel=4
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
ok  	github.com/terraform-providers/terraform-provider-aws/aws	1.807s

This addresses a bug when new VPCs are inserted into the associated VPC list of a route 53 zone.

The Setup

  • A Route 53 zone which have 2+ VPCs associated
  • Then a new VPC is inserted into the list of associated VPCs

Module "zone"

# Input
variable "name" {
  description = "The name of the internal zone"
}

variable "associated_vpc_ids" {
  description = "The list of VPC IDs to associate with this zone"
  type        = "list"
}

variable "associated_vpc_regions" {
  description = "The list of VPC regions for the aforementioned VPC IDs"
  type        = "list"
}

# Resources
resource "aws_route53_zone" "primary" {
  name       = "${var.name}"
  comment    = "${var.comment}"
  vpc_id     = "${var.associated_vpc_ids[0]}"
  vpc_region = "${var.associated_vpc_regions[0]}"
}

resource "aws_route53_zone_association" "additional" {
  count      = "${length(var.associated_vpc_ids) - 1}"
  zone_id    = "${aws_route53_zone.primary.zone_id}"
  vpc_id     = "${element(var.associated_vpc_ids, count.index + 1)}"
  vpc_region = "${element(var.associated_vpc_regions, count.index + 1)}"
}

Zone "Foo" - Version 1

module "zone-foo" {
  source = "zone"

  name                   = "foo.com."
  associated_vpc_ids     = ["vpc1", "vpc2"]
  associated_vpc_regions = "["us-west-1", "us-east-1"]
}

Zone "Foo" - Version 2

module "zone-foo" {
  source = "zone"

  name                   = "foo.com."
  associated_vpc_ids     = ["vpc1", "vpc-new", "vpc2"]
  associated_vpc_regions = "["us-west-1", "us-west-2", "us-east-1"]
}

The Problem

After version 2 is applied, the terraform state does have vpc-new, but its vpc region is us-east-1, instead of us-west-2, because terraform thinks the second associated VPC has changed from vpc2 to vpc-new, but it does not update vpc region in this update.

@bflad bflad added bug Addresses a defect in current functionality. service/route53 Issues and PRs that pertain to the route53 service. labels Aug 31, 2018
@bflad bflad closed this in #6299 Oct 30, 2018
@bflad
Copy link
Contributor

bflad commented Oct 30, 2018

Hi @yuan-stripe 👋 Thanks for submitting this and sorry for the delay in review. It turns out this was handled by a larger refactoring of the aws_route53_zone resource to support multiple VPC associations, which will be supported in version 1.42.0 of the AWS provider. As for the aws_route53_zone_association resource, it will be receiving its own refactoring very shortly to use some of the simpler code just introduced and fix some other bugs in the same process.

@ghost
Copy link

ghost commented Apr 2, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/route53 Issues and PRs that pertain to the route53 service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants