PARALLAX

cloudfront_distribution

Create, update and delete AWS CloudFront distributions

Collection: community.aws

Full Name: community.aws.cloudfront_distribution

Synopsis

Create, update and delete AWS CloudFront distributions

Parameters

NameTypeRequiredDefaultDescription
access_keystr
aliasstr
aliaseslist[]
aws_ca_bundlepath
aws_configdict
cache_behaviorslist
caller_referencestr
commentstr
custom_error_responseslist
debug_botocore_endpoint_logsboolfalse
default_cache_behaviordict
default_origin_domain_namestr
default_origin_pathstr
default_root_objectstr
distribution_idstr
e_tagstr
enabledbool
endpoint_urlstr
http_versionstr
ipv6_enabledbool
loggingdict
originslist
price_classstr
profilestr
purge_aliasesboolfalse
purge_cache_behaviorsboolfalse
purge_custom_error_responsesboolfalse
purge_originsboolfalse
purge_tagsbooltrue
regionstr
restrictionsdict
secret_keystr
session_tokenstr
statestrpresent
tagsdict
validate_certsbooltrue
viewer_certificatedict
waitboolfalse
wait_timeoutint1800
web_acl_idstr

Example

yaml
- name: create a basic distribution with defaults and tags
  community.aws.cloudfront_distribution:
    state: present
    default_origin_domain_name: www.my-cloudfront-origin.com
    tags:
        Name: example distribution
        Project: example project
        Priority: '1'

- name: update a distribution comment by distribution_id
  community.aws.cloudfront_distribution:
    state: present
    distribution_id: E1RP5A2MJ8073O
    comment: modified by ansible cloudfront.py

- name: update a distribution comment by caller_reference
  community.aws.cloudfront_distribution:
    state: present
    caller_reference: my cloudfront distribution 001
    comment: modified by ansible cloudfront.py

- name: update a distribution's aliases and comment using the distribution_id as a reference
  community.aws.cloudfront_distribution:
    state: present
    distribution_id: E1RP5A2MJ8073O
    comment: modified by cloudfront.py again
    aliases:
        - 'www.my-distribution-source.com'
        - 'zzz.aaa.io'

- name: update a distribution's aliases and comment using an alias as a reference
  community.aws.cloudfront_distribution:
    state: present
    caller_reference: my test distribution
    comment: modified by cloudfront.py again
    aliases:
        - www.my-distribution-source.com
        - zzz.aaa.io

- name: update a distribution's comment and aliases and tags and remove existing tags
  community.aws.cloudfront_distribution:
    state: present
    distribution_id: E15BU8SDCGSG57
    comment: modified by cloudfront.py again
    aliases:
        - tested.com
    tags:
        Project: distribution 1.2
    purge_tags: true

- name: create a distribution with an origin, logging and default cache behavior
  community.aws.cloudfront_distribution:
    state: present
    caller_reference: unique test distribution ID
    origins:
        - id: 'my test origin-000111'
          domain_name: www.example.com
          origin_path: /production
          custom_headers:
            - header_name: MyCustomHeaderName
              header_value: MyCustomHeaderValue
    default_cache_behavior:
        target_origin_id: 'my test origin-000111'
        forwarded_values:
            query_string: true
            cookies:
                forward: all
            headers:
                - '*'
        viewer_protocol_policy: allow-all
        smooth_streaming: true
        compress: true
        allowed_methods:
            items:
                - GET
                - HEAD
            cached_methods:
                - GET
                - HEAD
    logging:
        enabled: true
        include_cookies: false
        bucket: mylogbucket.s3.amazonaws.com
        prefix: myprefix/
    enabled: false
    comment: this is a CloudFront distribution with logging

- name: delete a distribution
  community.aws.cloudfront_distribution:
    state: absent
    caller_reference: replaceable distribution
Search
    ↑ ↓ move↵ openesc close