# Bug in community.aws.cloudfront\_distribution

**URL:** <https://forum.ansible.com/t/bug-in-community-aws-cloudfront-distribution/39206>\
**Category:** Collection Development\
**Tags:** aws\
**Created:** [December 17, 2024, 12:06pm UTC](https://forum.ansible.com/t/bug-in-community-aws-cloudfront-distribution/39206 "2024-12-17T12:06:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alvaro\_Morillas](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alvaro_morillas/32/7017_2.png) [@Alvaro\_Morillas](https://forum.ansible.com/u/Alvaro_Morillas)\
**Post date:** [December 17, 2024, 12:06pm UTC](https://forum.ansible.com/t/bug-in-community-aws-cloudfront-distribution/39206/1 "2024-12-17T12:06:57Z")

</div>

Hi all!

When trying to create a Cloudfront distribution I used this workbook:

```auto
- name: Setup Cache CloudFront distribution
  community.aws.cloudfront_distribution:
    alias: 'cache-{{ environment }}'
    aws_access_key: '{{ aws_key }}'
    aws_secret_key: '{{ aws_secret }}'
    comment: comment
    default_cache_behavior:
      forwarded_values:
        allowed_methods:
          cached_methods:
            - GET
            - HEAD
          items:
            - GET
            - HEAD
            - POST
            - PUT
            - DELETE
            - OPTIONS
            - PATCH
        compress: true
        cookies:
          forward: none
        default_ttl: 86400
        headers:
          - '*'
        min_ttl: 0
        max_ttl: 31536000
        query_string: true
        viewer_protocol_policy: https-only
      origin_request_policy_id: '{{ cache_cloudfront_distribution_allviewer_policy_id }}'
      target_origin_id: '{{ cache_cloudfront_distribution_origin_id }}'
    default_root_object: index.html
    enabled: true
    origins:
      - id: '{{ cache_cloudfront_distribution_origin_id }}'
        domain_name: '{{ cache_cloudfront_distribution_origin_domain_name }}'
        custom_origin_config:
          http_port: 80
          https_port: 443
          origin_protocol_policy: https-only
          origin_ssl_protocols:
            - TLSv1.2
          origin_read_timeout: 50
          origin_keepalive_timeout: 55
        origin_shield:
          enabled: true
          origin_shield_region: '{{ cache_cloudfront_distribution_origin_shield_region }}'
    price_class: PriceClass_All
    restrictions:
      geo_restriction:
        restriction_type: none
    state: present
    viewer_certificate:
      cloudfront_default_certificate: true
      minimum_protocol_version: TLSv1.2_2021
  register: cache_cloudfront

- name: Setup Cache CloudFront distribution details
  debug:
    msg: "{{ cache_cloudfront.distribution }}"

```

Then I got this error:

```auto
Error validating distribution origins: 'list' object has no attribute 'get'

```

And the following details:

```auto
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_community.aws.cloudfront_distribution_payload_6z9a8c6a/ansible_community.aws.cloudfront_distribution_payload.zip/ansible_collections/community/aws/plugins/modules/cloudfront_distribution.py", line 1762, in validate_origins
    origin = self.validate_origin(
             ^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/ansible_community.aws.cloudfront_distribution_payload_6z9a8c6a/ansible_community.aws.cloudfront_distribution_payload.zip/ansible_collections/community/aws/plugins/modules/cloudfront_distribution.py", line 1866, in validate_origin
    if custom_origin_config.get("origin_ssl_protocols", {}).get("items"):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'

```

So it looks like `origin_ssl_protocols` is not a list, but an object that expects an `items` entry. That’s not what the documentation says: [community.aws.cloudfront\_distribution module – Create, update and delete AWS CloudFront distributions — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/collections/community/aws/cloudfront_distribution_module.html#parameter-origins/custom_origin_config/origin_ssl_protocols)

I’m using ansible-core 2.16.1 and community.aws:8.0.0.

I hope this is of interest for everyone.

Kind regards!  
Álvaro Morillas

---

<div class="post-metadata">

**Author:** ![markuman](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@markuman](https://forum.ansible.com/u/markuman)\
**Post date:** [January 7, 2025, 9:38am UTC](https://forum.ansible.com/t/bug-in-community-aws-cloudfront-distribution/39206/2 "2025-01-07T09:38:37Z")

</div>

It’s

```yml
origin_ssl_protocols:
  items:
    - TLSv1.2
  quantity: 1

```

---

<div class="post-metadata">

**Author:** ![Alvaro\_Morillas](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alvaro_morillas/32/7017_2.png) [@Alvaro\_Morillas](https://forum.ansible.com/u/Alvaro_Morillas)\
**Post date:** [January 7, 2025, 9:54am UTC](https://forum.ansible.com/t/bug-in-community-aws-cloudfront-distribution/39206/3 "2025-01-07T09:54:58Z")

</div>

I suggest that the documentation states it better. I guess this is not the only case and that will lead to misunderstandings like mine.
