Skip to content

Commit

Permalink
Add support for disabling route53 health checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Oct 12, 2021
1 parent e3a50c4 commit 8beca00
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 1 deletion.
19 changes: 19 additions & 0 deletions plugins/modules/route53_health_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
choices: [ 'present', 'absent' ]
type: str
default: 'present'
disabled:
description:
- Stops Route 53 from performing health checks.
- See the AWS documentation for more details on the exact implications.
U(https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/health-checks-creating-values.html)
- Defaults to C(true) when creating a new health check.
type: bool
ip_address:
description:
- IP address of the end-point to check. Either this or I(fqdn) has to be provided.
Expand Down Expand Up @@ -185,6 +192,11 @@
type: str
returned: When the health check exists and a search string has been configured.
sample: 'ALIVE'
disabled:
description: Whether the health check has been disabled or not.
type: bool
returned: When the health check exists.
sample: false
'''

import uuid
Expand Down Expand Up @@ -278,6 +290,8 @@ def create_health_check(ip_addr_in, fqdn_in, type_in, request_interval_in, port_
RequestInterval=request_interval_in,
Port=port_in,
)
if module.params.get('disabled') is not None:
health_check['Disabled'] = module.params.get('disabled')
if ip_addr_in:
health_check['IPAddress'] = ip_addr_in
if fqdn_in:
Expand Down Expand Up @@ -341,6 +355,10 @@ def update_health_check(existing_check):
if failure_threshold and failure_threshold != existing_config.get('FailureThreshold'):
changes['FailureThreshold'] = failure_threshold

disabled = module.params.get('disabled', None)
if disabled is not None and disabled != existing_config.get('Disabled'):
changes['Disabled'] = module.params.get('disabled')

# No changes...
if not changes:
return False, None
Expand Down Expand Up @@ -383,6 +401,7 @@ def describe_health_check(id):
def main():
argument_spec = dict(
state=dict(choices=['present', 'absent'], default='present'),
disabled=dict(type='bool'),
ip_address=dict(),
port=dict(type='int'),
type=dict(required=True, choices=['HTTP', 'HTTPS', 'HTTP_STR_MATCH', 'HTTPS_STR_MATCH', 'TCP']),
Expand Down
Loading

0 comments on commit 8beca00

Please sign in to comment.