Skip to content

Commit

Permalink
add skeleton implementation of request certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-rosset committed Jan 18, 2022
1 parent 4eb1996 commit 4235a3c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugins/modules/aws_acm.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,20 @@ def pem_chain_split(module, pem):
def request_certificate(client, module, acm, desired_tags):
cert_request = module.get('certificate_request')
domain_name = module.params.get('domain_name')
if domain_name is None:
module.fail_json(msg="The 'domain_name' parameter must be specified when requesting a certificate from ACM")
cert_options = cert_request.get('options')
options = {
'CertificateTransparencyLoggingPreference': 'ENABLED',
}
if cert_options is not None and cert_options.get('certificate_transparency_logging_preference') is not None:
options['CertificateTransparencyLoggingPreference'] = cert_options.get('certificate_transparency_logging_preference')

if module.check_mode:
module.exit_json(
changed=True, msg="Would have requested certificate if not in check mode"
)
response = None
try:
response = client.request_certificate(
DomainName=domain_name,
Expand All @@ -502,6 +509,9 @@ def request_certificate(client, module, acm, desired_tags):
)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, "Couldn't request certificate for {0}".format(domain_name))
cert_arn = response.get('CertificateARN')
domain = acm.get_domain_of_cert(client=client, module=module, arn=cert_arn)
module.exit_json(certificate=dict(domain_name=domain, arn=cert_arn, tags=desired_tags), changed=True)

def update_imported_certificate(client, module, acm, old_cert, desired_tags):
"""
Expand Down

0 comments on commit 4235a3c

Please sign in to comment.