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

Added measure_latency option to Route 53 Health Check resource. #3688

Merged
merged 2 commits into from
Jan 7, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions builtin/providers/aws/resource_aws_route53_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func resourceAwsRoute53HealthCheck() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"measure_latency": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"tags": tagsSchema(),
},
}
Expand Down Expand Up @@ -128,6 +133,10 @@ func resourceAwsRoute53HealthCheckCreate(d *schema.ResourceData, meta interface{
healthConfig.ResourcePath = aws.String(v.(string))
}

if v, ok := d.GetOk("measure_latency"); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema elements with a Default value do not need to be checked with GetOk; it will always be ok. Here, healthConfig.MeasureLatency = aws.Bool(d.Get("measure_latency").(bool)) is fine.

Also, since this is a boolean, if the user specified false in their configuration this block would never be entered. since GetOk checks for non-default values. Not that you should have known these things, just mentioning it 😄

healthConfig.MeasureLatency = aws.Bool(v.(bool))
}

input := &route53.CreateHealthCheckInput{
CallerReference: aws.String(time.Now().Format(time.RFC3339Nano)),
HealthCheckConfig: healthConfig,
Expand Down Expand Up @@ -174,6 +183,7 @@ func resourceAwsRoute53HealthCheckRead(d *schema.ResourceData, meta interface{})
d.Set("ip_address", updated.IPAddress)
d.Set("port", updated.Port)
d.Set("resource_path", updated.ResourcePath)
d.Set("measure_latency", updated.MeasureLatency)

// read the tags
req := &route53.ListTagsForResourceInput{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ resource "aws_route53_health_check" "foo" {
resource_path = "/"
failure_threshold = "2"
request_interval = "30"
measure_latency = true

tags = {
Name = "tf-test-health-check"
Expand Down