Change aws_acm_facts name parameter to be domain_name (#36986)

Match AWS's naming for domain name, but provide backward
compatible alias.
pull/39622/merge
Will Thames 7 years ago committed by Ryan Brown
parent cb4db82354
commit b5488b4e45

@ -13,9 +13,11 @@ description:
- Retrieve facts for ACM certificates - Retrieve facts for ACM certificates
version_added: "2.5" version_added: "2.5"
options: options:
name: domain_name:
description: description:
- The name of an ACM certificate - The domain name of an ACM certificate to limit the search to
aliases:
- name
status: status:
description: description:
- Status to filter the certificate results - Status to filter the certificate results
@ -36,7 +38,7 @@ EXAMPLES = '''
- name: obtain all facts for a single ACM certificate - name: obtain all facts for a single ACM certificate
aws_acm_facts: aws_acm_facts:
name: "*.example_com" domain_name: "*.example_com"
- name: obtain all certificates pending validiation - name: obtain all certificates pending validiation
aws_acm_facts: aws_acm_facts:
@ -264,16 +266,16 @@ def list_certificate_tags_with_backoff(client, certificate_arn):
return client.list_tags_for_certificate(CertificateArn=certificate_arn)['Tags'] return client.list_tags_for_certificate(CertificateArn=certificate_arn)['Tags']
def get_certificates(client, module, name=None, statuses=None): def get_certificates(client, module, domain_name=None, statuses=None):
try: try:
all_certificates = list_certificates_with_backoff(client, statuses) all_certificates = list_certificates_with_backoff(client, statuses)
except botocore.exceptions.ClientError as e: except botocore.exceptions.ClientError as e:
module.fail_json(msg="Couldn't obtain certificates", module.fail_json(msg="Couldn't obtain certificates",
exception=traceback.format_exc(), exception=traceback.format_exc(),
**camel_dict_to_snake_dict(e.response)) **camel_dict_to_snake_dict(e.response))
if name: if domain_name:
certificates = [cert for cert in all_certificates certificates = [cert for cert in all_certificates
if cert['DomainName'] == name] if cert['DomainName'] == domain_name]
else: else:
certificates = all_certificates certificates = all_certificates
@ -308,7 +310,7 @@ def main():
argument_spec = ec2_argument_spec() argument_spec = ec2_argument_spec()
argument_spec.update( argument_spec.update(
dict( dict(
name=dict(), domain_name=dict(aliases=['name']),
statuses=dict(type='list'), statuses=dict(type='list'),
) )
) )
@ -321,7 +323,7 @@ def main():
client = boto3_conn(module, conn_type='client', resource='acm', client = boto3_conn(module, conn_type='client', resource='acm',
region=region, endpoint=ec2_url, **aws_connect_kwargs) region=region, endpoint=ec2_url, **aws_connect_kwargs)
certificates = get_certificates(client, module, name=module.params['name'], statuses=module.params['statuses']) certificates = get_certificates(client, module, domain_name=module.params['domain_name'], statuses=module.params['statuses'])
module.exit_json(certificates=certificates) module.exit_json(certificates=certificates)

Loading…
Cancel
Save