terraform-provider-aws: aws_route53_zone resource fails when used with count
This issue was originally opened by @nick-o as hashicorp/terraform#12282. It was migrated here as part of the provider split. The original body of the issue is below.
Hi there,
I’ve run into a strange issue when trying to create multiple Route53 zones via single resource and count. It seems that the code to do so only generates a unique caller reference once (see here) which then gets used for multiple API calls.
Terraform Version
terraform -v Terraform v0.8.7
Affected Resource(s)
- aws_route53_zone
Terraform Configuration Files
variable "route53_zone_names" {
type = "list"
default = [
"dev",
"tst",
"ppd"
]
}
resource "aws_route53_zone" "public" {
count = "${length(var.route53_zone_names)}"
name = "${element(var.route53_zone_names,count.index)}.project.abc.com"
}
Debug Output
https://gist.github.com/nick-o/d0b5a4e7ce5ef4e0ba9d74353daa518e
Panic Output
Expected Behavior
3 Public Route53 Zones should be created
Actual Behavior
Only one zone got created. The other 2 fail to get created due to non-unique caller reference
> terraform apply
aws_route53_zone.public.0: Creating...
comment: "" => "Managed by Terraform"
force_destroy: "" => "false"
name: "" => "dev.project.abc.com"
name_servers.#: "" => "<computed>"
vpc_region: "" => "<computed>"
zone_id: "" => "<computed>"
aws_route53_zone.public.2: Creating...
comment: "" => "Managed by Terraform"
force_destroy: "" => "false"
name: "" => "ppd.project.abc.com"
name_servers.#: "" => "<computed>"
vpc_region: "" => "<computed>"
zone_id: "" => "<computed>"
aws_route53_zone.public.1: Creating...
comment: "" => "Managed by Terraform"
force_destroy: "" => "false"
name: "" => "tst.project.abc.com"
name_servers.#: "" => "<computed>"
vpc_region: "" => "<computed>"
zone_id: "" => "<computed>"
aws_route53_zone.public.1: Still creating... (10s elapsed)
aws_route53_zone.public.1: Still creating... (20s elapsed)
aws_route53_zone.public.1: Still creating... (30s elapsed)
aws_route53_zone.public.1: Still creating... (40s elapsed)
aws_route53_zone.public.1: Creation complete
Error applying plan:
2 error(s) occurred:
* aws_route53_zone.public.2: HostedZoneAlreadyExists: A hosted zone has already been created with the specified caller reference.
status code: 409, request id: 151ed321-fd19-11e6-b1d9-afb55cf95a01
* aws_route53_zone.public.0: HostedZoneAlreadyExists: A hosted zone has already been created with the specified caller reference.
status code: 409, request id: 151eac19-fd19-11e6-9011-f1429215f6fa
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
Important Factoids
N/A
References
See AWS CLI documentation for explanation of caller-reference. I think the problem stems from trying to create all 3 zones in one go and it will try to use the same caller reference.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 20 (5 by maintainers)
The fix for this has been merged in via #4341 and will release with v1.17.0 of the AWS provider, likely in a week.
Hi @pawelsocha Facing the same issue in Terraform
v0.11.3with aws provider version1.9.0. However when I degrade my version to Terraformv.10.8with aws provider version1.9.0, it works.Meanwhile I can avoid this, if I pass
parallelism=1in theterraform applyfor versionv0.11.3and aws provider version1.9.0I am running into the same issue on Terraform
0.11.7with aws provider version1.14.1. Adding theparallelism=1flag to apply did help me get pass this issue. Thanks @anshulpatel25