Skip to content

Commit

Permalink
r/aws_route53_health_check: Validate reference_name (#12873)
Browse files Browse the repository at this point in the history
Support plan-time validation for the length of the reference_name
argument. Since this resource auto-appends a unique string to the
provided argument, this is necessary to avoid obtuse errors on apply.
This validates the provided reference_name plus the generated string is
no longer than 64 chars, the actual API limit.

Since the generated unique ID is 37 chars, the `reference_name` argument
cannot exceed 27 characters.

Closes #7248

Co-Authored-By: Brian Flad <bflad417@gmail.com>

Co-authored-by: Brian Flad <bflad417@gmail.com>
  • Loading branch information
timoguin and bflad committed Apr 29, 2020
1 parent 21d38d8 commit 17d4b94
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions aws/resource_aws_route53_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ func resourceAwsRoute53HealthCheck() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
// The max length of the reference name is 64 characters for the API.
// Terraform appends a 37-character unique ID to the provided
// reference_name. This limits the length of the resource argument to 27.
//
// Example generated suffix: -terraform-20190122200019880700000001
ValidateFunc: validation.StringLenBetween(0, (64 - resource.UniqueIDSuffixLength - 11)),
},
"enable_sni": {
Type: schema.TypeBool,
Expand Down

0 comments on commit 17d4b94

Please sign in to comment.