ansible-collections / community.aws

Ansible Collection for Community AWS
GNU General Public License v3.0
188 stars 397 forks source link

[aws_acm_info] DomainValidationOptions.ResourceRecord not Available in Response #321

Open muya opened 3 years ago

muya commented 3 years ago
SUMMARY

When requesting for a certificate using the acm AWS module, there's an option to use either email validation or DNS validation.

When the DNS option is chosen, the describe certificate response is expected to have a ResourceRecord field, which has details of what to configure to allow domain validation (see "ResourceRecord" in the official AWS documentation).

However, this field is not available in the response from the community.aws.aws_acm_info module.

ISSUE TYPE
COMPONENT NAME

community.aws.aws_acm_info

ANSIBLE VERSION
ansible 2.10.3
  config file = None
  configured module search path = ['/path/to/home/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.10.3/libexec/lib/python3.9/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.9.0 (default, Nov 14 2020, 10:50:03) [Clang 12.0.0 (clang-1200.0.32.27)]
CONFIGURATION
(empty output)
OS / ENVIRONMENT
STEPS TO REPRODUCE
# Task to request certificate via shell command (requires `aws` CLI)
- name: "Request for Certificate on ACM"
  shell: |
     aws acm request-certificate --domain-name "{{ domain_name }}" --validation-method "DNS"
  environment:
    AWS_ACCESS_KEY_ID: "{{ acm_aws_access_key }}"
    AWS_SECRET_ACCESS_KEY: "{{ acm_aws_secret_key }}"
    AWS_REGION: "{{ aws_default_region }}"
  register: request_cert_result

# Inspect successful result
- name: "Inspect successful certificate result"
  set_fact:
    request_certificate_output: "{{ request_cert_result['stdout'] | from_json }}"
  when:
    request_cert_result is not failed

# Fetch certificate info
- name: "Fetch Certificate Information"
  community.aws.aws_acm_info:
    aws_access_key: "{{ acm_aws_access_key }}"
    aws_secret_key: "{{ acm_aws_secret_key }}"
    aws_region: "{{ aws_default_region }}"
    certificate_arn: "{{ request_certificate_output.CertificateArn }}"
EXPECTED RESULTS
aws_acm_describe-certificate
ACTUAL RESULTS
See output in screenshot
acm_info_output
muya commented 3 years ago

Update: Noticed that the resource_record value becomes available in the response if the query is ran a few seconds later (possible because AWS takes some time to create the DNS record required for validation?)

We may only need to update the documentation for this module to:

goneri commented 3 years ago

Hi @muya,

Would you like to push a PR to improve the documentation as you suggested? Otherwise can we close the issue?

muya commented 3 years ago

Hi @muya,

Would you like to push a PR to improve the documentation as you suggested? Otherwise can we close the issue?

@goneri I'm definitely up for doing this when I get some time ✅