Repository: ansible-collections/amazon.aws

Issue:
route53_health_check - Add support for Latency graphs (MeasureLatency) during creation
### Summary

Add support for Latency graphs (MeasureLatency) during creation of a Route53 Health Check

#### Reference
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/route53.html#Route53.Client.create_health_check

> **MeasureLatency (boolean)**
Specify whether you want Amazon Route 53 to measure the latency between health checkers in multiple Amazon Web Services regions and your endpoint, and to display CloudWatch latency graphs on the Health Checks page in the Route 53 console.

### Issue Type

Feature Idea

### Component Name

route53_health_check

### Additional Information

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)

```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/route53_health_check.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/route53_health_check.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @jillr @s-hertel @tremble @zimbatm
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/route53_health_check.py b/plugins/modules/route53_health_check.py
--- a/plugins/modules/route53_health_check.py
+++ b/plugins/modules/route53_health_check.py
@@ -113,6 +113,14 @@
     aliases: ['id']
     version_added: 4.1.0
     version_added_collection: community.aws
+  measure_latency:
+    description:
+      - To enable/disable latency graphs to monitor the latency between health checkers in multiple Amazon Web Services regions and your endpoint.
+      - Value of I(measure_latency) is immutable and can not be modified after creating a health check.
+        See U(https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/monitoring-health-check-latency.html)
+    type: bool
+    required: False
+    version_added: 5.4.0
 author:
   - "zimbatm (@zimbatm)"
 notes:
@@ -157,6 +165,16 @@
     type: HTTPS
     use_unique_names: true
 
+- name: create a TCP health check with latency graphs enabled
+  amazon.aws.route53_health_check:
+    state: present
+    health_check_name: ansible
+    fqdn: ansible.com
+    port: 443
+    type: HTTPS
+    use_unique_names: true
+    measure_latency: true
+
 - name: Delete health-check
   amazon.aws.route53_health_check:
     state: absent
@@ -392,6 +410,9 @@ def create_health_check(ip_addr_in, fqdn_in, type_in, request_interval_in, port_
         failure_threshold = 3
     health_check['FailureThreshold'] = failure_threshold
 
+    if module.params.get('measure_latency') is not None:
+        health_check['MeasureLatency'] = module.params.get('measure_latency')
+
     if missing_args:
         module.fail_json(msg='missing required arguments for creation: {0}'.format(
             ', '.join(missing_args)),
@@ -513,6 +534,7 @@ def main():
         health_check_id=dict(type='str', aliases=['id'], required=False),
         health_check_name=dict(type='str', aliases=['name'], required=False),
         use_unique_names=dict(type='bool', required=False),
+        measure_latency=dict(type='bool', required=False),
     )
 
     args_one_of = [


Test patch:
diff --git a/tests/integration/targets/route53_health_check/tasks/main.yml b/tests/integration/targets/route53_health_check/tasks/main.yml
--- a/tests/integration/targets/route53_health_check/tasks/main.yml
+++ b/tests/integration/targets/route53_health_check/tasks/main.yml
@@ -1696,12 +1696,67 @@
       - delete_complex is successful
       - delete_complex is not changed
 
+  # Minimum possible definition
+  - name: 'Create a TCP health check with latency graphs enabled'
+    route53_health_check:
+      state: present
+      health_check_name: '{{ tiny_prefix }}-hc-latency-graph'
+      use_unique_names: true
+      ip_address: '{{ ip_address }}'
+      port: '{{ port }}'
+      type: '{{ type }}'
+      measure_latency: true
+    register: create_check
+
+  - name: Get health check info
+    amazon.aws.route53_info:
+      query: health_check
+      health_check_id: "{{ create_check.health_check.id }}"
+      health_check_method: details
+    register: health_check_info
+
+  - name: 'Check result - Create a TCP health check with latency graphs enabled'
+    assert:
+      that:
+      - create_check is successful
+      - create_check is changed
+      - health_check_info.health_check.health_check_config.measure_latency == true
+
+  - name: 'Update above health check to disable latency graphs - immutable, no change'
+    route53_health_check:
+      state: present
+      health_check_name: '{{ tiny_prefix }}-hc-latency-graph'
+      use_unique_names: true
+      ip_address: '{{ ip_address }}'
+      port: '{{ port }}'
+      type: '{{ type }}'
+      measure_latency: false
+    register: update_check
+
+  - name: 'Check result - Update TCP health check to disable latency graphs'
+    assert:
+      that:
+      - update_check is successful
+      - update_check is not changed
+      - health_check_info.health_check.health_check_config.measure_latency == true
+
   always:
 
     ################################################
     # TEARDOWN STARTS HERE
     ################################################
 
+  - name: 'Delete TCP health check with latency graphs enabled'
+    route53_health_check:
+      state: absent
+      health_check_name: '{{ tiny_prefix }}-hc-latency-graph'
+      use_unique_names: true
+      ip_address: '{{ ip_address }}'
+      port: '{{ port }}'
+      type: '{{ type }}'
+      measure_latency: true
+    ignore_errors: true
+
   - name: 'Delete TCP health check'
     route53_health_check:
       state: absent