From fe55eec975360944a59e28b1b96b50d419a8a1cf Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 9 Jan 2024 15:49:37 -0800 Subject: [PATCH 01/70] New Module: cloudfront_cache_policy --- meta/runtime.yml | 1 + plugins/modules/cloudfront_cache_policy.py | 452 ++++++++++++++++++ .../targets/cloudfront_cache_policy/aliases | 1 + .../cloudfront_cache_policy/meta/main.yml | 1 + .../cloudfront_cache_policy/tasks/main.yml | 119 +++++ 5 files changed, 574 insertions(+) create mode 100644 plugins/modules/cloudfront_cache_policy.py create mode 100644 tests/integration/targets/cloudfront_cache_policy/aliases create mode 100644 tests/integration/targets/cloudfront_cache_policy/meta/main.yml create mode 100644 tests/integration/targets/cloudfront_cache_policy/tasks/main.yml diff --git a/meta/runtime.yml b/meta/runtime.yml index 4c6bc72910d..c24f616b885 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -66,6 +66,7 @@ action_groups: - batch_job_queue - cloudformation_exports_info - cloudformation_stack_set + - cloudfront_cache_policy - cloudfront_distribution - cloudfront_distribution_info - cloudfront_info diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py new file mode 100644 index 00000000000..03213f5e524 --- /dev/null +++ b/plugins/modules/cloudfront_cache_policy.py @@ -0,0 +1,452 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2024 Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +version_added: 7.2.0 +module: cloudfront_cache_policy + +short_description: Create, update and delete cache policies to be used in a Cloudfront distribution + +description: + - Create, update and delete cache policies to be used in a Cloudfront distribution for configurating the cache key as well as the default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache + - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_cache_policy.html) + +author: + - Zac Lovoy (@zwlovoy) + +options: + state: + description: Decides if the named policy should be absent or present. + choices: + - present + - absent + default: present + type: str + name: + description: A unique name to identify the cache policy. + required: true + type: str + comment: + description: A comment to describe the cache policy. The comment cannot be longer than 128 characters. + required: false + type: str + default_ttl: + description: The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + required: false + type: int + min_ttl: + description: The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + required: true + type: int + max_ttl: + description: The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + required: false + type: int + parameters_in_cache_key_and_forwarded_to_origin + description: + - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) + required: false + default: {} + type: dict + suboptions: + enable_accept_encoding_gzip: + description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + type: bool + required: true + enable_accept_encoding_brotli: + description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + type: bool + required: true + headers_config: + description: + - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) + type: dict + required: true + suboptions: + header_behavior: + description: Determines whether any HTTP headers are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist'] + type: str + required: true + headers: + description: + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + type: list + elements: str + required: false + cookies_config: + description: + - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) + required: true + type: dict + suboptions: + cookie_behavior: + description: Determines whether any cookies in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + required: true + type: str + cookies: + description: + - Contains a list of cookie names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + type: list + elements: str + required: false + query_strings_config: + description: + - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) + required: true + type: dict + suboptions: + query_string_behavior: + description: Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + required: true + type: str + query_strings: + description: + - Contains the specific query strings in viewer requests that either are or are not included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + type: list + elements: str + required: false + +extends_documentation_fragment: + - amazon.aws.common.modules + - amazon.aws.region.modules + - amazon.aws.boto3 +""" + +EXAMPLES = r""" +- name: Creating a basic CloudFront cache policy with required fields and basic parameters_in_cache_key_and_forwarded_to_origin for demonstration + community.aws.cloudfront_cache_policy: + name: my-cache-policy + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: true + enable_accept_encoding_brotli: true + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + +- name: Creating a CloudFront cache policy using all predefined parameters_in_cache_key_and_forwarded_to_origin properties for demonstration + community.aws.cloudfront_cache_policy: + name: my-cache-policy + comment: My cache policy for my CloudFront distribution + default_ttl: 86400 + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: true + enable_accept_encoding_brotli: true + headers_config: + header_behavior: whitelist + headers: + items: + - accept + - accept-language + - host + - user-agent + cookies_config: + cookie_behavior: whitelist + cookies: + items: + - my-cookie + query_strings_config: + query_string_behavior: whitelist + query_strings: + items: + - my-query-string + state: present + +- name: Delete header policy + community.aws.cloudfront_cache_policy: + name: my-cache-policy + state: absent +""" + +RETURN = r""" +cache_policy: + description: The policy's information + returned: success + type: complex + contains: + id: + description: The unique identifier for the cache policy. + returned: always + type: str + sample: 'b2884449-e4de-46a7-ac36-70bc7f1ddd6d' + last_modified_time: + description: The timestamp when the cache policy was last modified. + returned: always + type: str + sample: '2022-02-04T13:23:27.304000+00:00' + cache_policy_config: + description: The cache policy configuration. + returned: always + type: complex + contains: + name: + description: A unique name to identify the cache policy. + type: str + returned: always + sample: my-cache-policy + comment: + description: A comment to describe the cache policy. + type: str + returned: always + sample: My cache policy for my CloudFront distribution + default_ttl: + description: The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + type: int + returned: always + sample: 86400 + min_ttl: + description: The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + type: int + returned: always + sample: 1 + max_ttl: + description: The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + type: int + returned: always + sample: 31536000 + parameters_in_cache_key_and_forwarded_to_origin + description: + - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) + required: false + default: {} + type: dict + suboptions: + enable_accept_encoding_gzip: + description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + type: bool + required: true + enable_accept_encoding_brotli: + description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + type: bool + required: true + headers_config: + description: + - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) + type: dict + required: true + suboptions: + header_behavior: + description: Determines whether any HTTP headers are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist'] + type: str + required: true + headers: + description: + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + type: list + elements: str + required: false + cookies_config: + description: + - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) + required: true + type: dict + suboptions: + cookie_behavior: + description: Determines whether any cookies in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + required: true + type: str + cookies: + description: + - Contains a list of cookie names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + type: list + elements: str + required: false + query_strings_config: + description: + - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) + required: true + type: dict + suboptions: + query_string_behavior: + description: Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + required: true + type: str + query_strings: + description: + - Contains the specific query strings in viewer requests that either are or are not included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + type: list + elements: str + required: false +""" + +import datetime + +try: + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError +except ImportError: + pass # caught by imported AnsibleAWSModule + +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict + +from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule + + +class CloudfrontCachePolicyService(object): + def __init__(self, module): + self.module = module + self.client = module.client("cloudfront") + self.check_mode = module.check_mode + + def find_cache_policy(self, name): + try: + policies = self.client.list_cache_policies()["CachePolicyList"]["Items"] + + for policy in policies: + if policy["CachePolicy"]["CachePolicyConfig"]["Name"] == name: + policy_id = policy["CachePolicy"]["Id"] + # as the list_ request does not contain the Etag (which we need), we need to do another get_ request here + matching_policy = self.client.get_cache_policy(Id=policy["CachePolicy"]["Id"]) + break + else: + matching_policy = None + + return matching_policy + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Error fetching policy information") + + def create_cache_policy(self, name, comment, default_ttl, min_ttl, max_ttl, parameters_in_cache_key_and_forwarded_to_origin): + parameters_in_cache_key_and_forwarded_to_origin = snake_dict_to_camel_dict(parameters_in_cache_key_and_forwarded_to_origin, capitalize_first=True) + + config = { + "Name": name, + "Comment": comment, + "DefaultTTL": default_ttl, + "MinTTL": min_ttl, + "MaxTTL": max_ttl, + "ParametersInCacheKeyAndForwardedToOrigin": self.insert_quantities(parameters_in_cache_key_and_forwarded_to_origin), + } + + config = {k: v for k, v in config.items() if v} + + matching_policy = self.find_cache_policy(name) + + changed = False + + if self.check_mode: + self.module.exit_json(changed=True, cache_policy=camel_dict_to_snake_dict(config)) + + if matching_policy is None: + try: + result = self.client.create_cache_policy(CachePolicyConfig=config) + changed = True + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Error creating policy") + else: + policy_id = matching_policy["CachePolicy"]["Id"] + etag = matching_policy["ETag"] + try: + result = self.client.update_cache_policy( + Id=policy_id, IfMatch=etag, CachePolicyConfig=config + ) + + changed_time = result["CachePolicy"]["LastModifiedTime"] + seconds = 3 # threshhold for returned timestamp age + seconds_ago = datetime.datetime.now(changed_time.tzinfo) - datetime.timedelta(0, seconds) + + # consider change made by this execution of the module if returned timestamp was very recent + if changed_time > seconds_ago: + changed = True + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Updating creating policy") + + self.module.exit_json(changed=changed, **camel_dict_to_snake_dict(result)) + + def delete_cache_policy(self, name): + matching_policy = self.find_cache_policy(name) + + if matching_policy is None: + self.module.exit_json(msg="Didn't find a matching policy by that name, not deleting") + else: + policy_id = matching_policy["CachePolicy"]["Id"] + etag = matching_policy["ETag"] + if self.check_mode: + result = {} + else: + try: + result = self.client.delete_cache_policy(Id=policy_id, IfMatch=etag) + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Error deleting policy") + + self.module.exit_json(changed=True, **camel_dict_to_snake_dict(result)) + + # Inserts a Quantity field into dicts with a list ('Items') + # Implementation from cloudfront_response_headers_policy.py + @staticmethod + def insert_quantities(dict_with_items): + # Items on top level case + if "Items" in dict_with_items and isinstance(dict_with_items["Items"], list): + dict_with_items["Quantity"] = len(dict_with_items["Items"]) + + # Items on second level case + for k, v in dict_with_items.items(): + if isinstance(v, dict) and "Items" in v: + v["Quantity"] = len(v["Items"]) + + return dict_with_items + +def main(): + argument_spec = dict( + name=dict(required=True, type="str"), + comment=dict(type="str"), + default_ttl=dict(type="int"), + min_ttl=dict(required=True, type="int"), + max_ttl=dict(type="int"), + parameters_in_cache_key_and_forwarded_to_origin=dict(type="dict", default=dict()), + state=dict(choices=["present", "absent"], type="str", default="present"), + ) + + module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) + + name = module.params.get("name") + comment = module.params.get("comment", "") + default_ttl = module.params.get("default_ttl") + min_ttl = module.params.get("min_ttl") + max_ttl = module.params.get("max_ttl") + parameters_in_cache_key_and_forwarded_to_origin = module.params.get("parameters_in_cache_key_and_forwarded_to_origin") + state = module.params.get("state") + + service = CloudfrontCachePolicyService(module) + + if state == "absent": + service.delete_cache_policy(name) + else: + service.create_cache_policy( + name, comment, default_ttl, min_ttl, max_ttl, parameters_in_cache_key_and_forwarded_to_origin + ) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/tests/integration/targets/cloudfront_cache_policy/aliases b/tests/integration/targets/cloudfront_cache_policy/aliases new file mode 100644 index 00000000000..4ef4b2067d0 --- /dev/null +++ b/tests/integration/targets/cloudfront_cache_policy/aliases @@ -0,0 +1 @@ +cloud/aws diff --git a/tests/integration/targets/cloudfront_cache_policy/meta/main.yml b/tests/integration/targets/cloudfront_cache_policy/meta/main.yml new file mode 100644 index 00000000000..32cf5dda7ed --- /dev/null +++ b/tests/integration/targets/cloudfront_cache_policy/meta/main.yml @@ -0,0 +1 @@ +dependencies: [] diff --git a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml new file mode 100644 index 00000000000..76d2b19f32f --- /dev/null +++ b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml @@ -0,0 +1,119 @@ +--- + +- name: Integration testing for the cloudfront_cache_policy module + module_defaults: + group/aws: + aws_access_key: '{{ aws_access_key }}' + aws_secret_key: '{{ aws_secret_key }}' + security_token: '{{ security_token | default(omit) }}' + region: '{{ aws_region }}' + block: + + - name: Create a simple cache policy + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-header-policy" + comment: Created by Ansible test + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: false + enable_accept_encoding_brotli: false + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + register: create_result + + - name: Assert creation without errors and return values + assert: + that: + - create_result is changed + - create_result is not failed + - create_result.cache_policy.cache_policy_config.name == "{{ resource_prefix }}-my-header-policy" + + - name: Rerun same task to ensure idempotence + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-header-policy" + comment: Created by Ansible test + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: false + enable_accept_encoding_brotli: false + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + register: rerun_result + + - name: Assert no change and no errors + assert: + that: + - rerun_result is not changed + - rerun_result is not failed + + - name: Update existing policy with more complicated configuration + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-header-policy" + comment: Created by Ansible test + default_ttl: 86400 + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: true + enable_accept_encoding_brotli: true + headers_config: + header_behavior: whitelist + headers: + items: + - accept + - accept-language + - host + - user-agent + cookies_config: + cookie_behavior: whitelist + cookies: + items: + - my-cookie + query_strings_config: + query_string_behavior: whitelist + query_strings: + items: + - my-query-string + state: present + register: update_result + + - name: Assert update and updated return values + assert: + that: + - update_result is changed + - update_result.cache_policy.cache_policy_config.cors_config.parameters_in_cache_key_and_forwarded_to_origin.enable_accept_encoding_gzip == true + - update_result.cache_policy.cache_policy_config.cors_config.parameters_in_cache_key_and_forwarded_to_origin.enable_accept_encoding_brotli == true + + - name: Ensure policy is deleted + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-header-policy" + comment: Created by Ansible test + state: absent + register: delete_result + + - name: Assert deletion without errors + assert: + that: + - delete_result is changed + - delete_result is not failed + - update_result.cache_policy is undefined + + always: + + - name: Ensure policy is deleted + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-header-policy" + state: absent + ignore_errors: true \ No newline at end of file From 2eb76d02947dce60a89278849225898236bb27e2 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 9 Jan 2024 15:49:37 -0800 Subject: [PATCH 02/70] New Module: cloudfront_cache_policy --- meta/runtime.yml | 1 + plugins/modules/cloudfront_cache_policy.py | 452 ++++++++++++++++++ .../targets/cloudfront_cache_policy/aliases | 1 + .../cloudfront_cache_policy/meta/main.yml | 1 + .../cloudfront_cache_policy/tasks/main.yml | 119 +++++ 5 files changed, 574 insertions(+) create mode 100644 plugins/modules/cloudfront_cache_policy.py create mode 100644 tests/integration/targets/cloudfront_cache_policy/aliases create mode 100644 tests/integration/targets/cloudfront_cache_policy/meta/main.yml create mode 100644 tests/integration/targets/cloudfront_cache_policy/tasks/main.yml diff --git a/meta/runtime.yml b/meta/runtime.yml index 4c6bc72910d..c24f616b885 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -66,6 +66,7 @@ action_groups: - batch_job_queue - cloudformation_exports_info - cloudformation_stack_set + - cloudfront_cache_policy - cloudfront_distribution - cloudfront_distribution_info - cloudfront_info diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py new file mode 100644 index 00000000000..03213f5e524 --- /dev/null +++ b/plugins/modules/cloudfront_cache_policy.py @@ -0,0 +1,452 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2024 Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +version_added: 7.2.0 +module: cloudfront_cache_policy + +short_description: Create, update and delete cache policies to be used in a Cloudfront distribution + +description: + - Create, update and delete cache policies to be used in a Cloudfront distribution for configurating the cache key as well as the default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache + - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_cache_policy.html) + +author: + - Zac Lovoy (@zwlovoy) + +options: + state: + description: Decides if the named policy should be absent or present. + choices: + - present + - absent + default: present + type: str + name: + description: A unique name to identify the cache policy. + required: true + type: str + comment: + description: A comment to describe the cache policy. The comment cannot be longer than 128 characters. + required: false + type: str + default_ttl: + description: The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + required: false + type: int + min_ttl: + description: The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + required: true + type: int + max_ttl: + description: The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + required: false + type: int + parameters_in_cache_key_and_forwarded_to_origin + description: + - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) + required: false + default: {} + type: dict + suboptions: + enable_accept_encoding_gzip: + description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + type: bool + required: true + enable_accept_encoding_brotli: + description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + type: bool + required: true + headers_config: + description: + - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) + type: dict + required: true + suboptions: + header_behavior: + description: Determines whether any HTTP headers are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist'] + type: str + required: true + headers: + description: + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + type: list + elements: str + required: false + cookies_config: + description: + - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) + required: true + type: dict + suboptions: + cookie_behavior: + description: Determines whether any cookies in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + required: true + type: str + cookies: + description: + - Contains a list of cookie names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + type: list + elements: str + required: false + query_strings_config: + description: + - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) + required: true + type: dict + suboptions: + query_string_behavior: + description: Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + required: true + type: str + query_strings: + description: + - Contains the specific query strings in viewer requests that either are or are not included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + type: list + elements: str + required: false + +extends_documentation_fragment: + - amazon.aws.common.modules + - amazon.aws.region.modules + - amazon.aws.boto3 +""" + +EXAMPLES = r""" +- name: Creating a basic CloudFront cache policy with required fields and basic parameters_in_cache_key_and_forwarded_to_origin for demonstration + community.aws.cloudfront_cache_policy: + name: my-cache-policy + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: true + enable_accept_encoding_brotli: true + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + +- name: Creating a CloudFront cache policy using all predefined parameters_in_cache_key_and_forwarded_to_origin properties for demonstration + community.aws.cloudfront_cache_policy: + name: my-cache-policy + comment: My cache policy for my CloudFront distribution + default_ttl: 86400 + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: true + enable_accept_encoding_brotli: true + headers_config: + header_behavior: whitelist + headers: + items: + - accept + - accept-language + - host + - user-agent + cookies_config: + cookie_behavior: whitelist + cookies: + items: + - my-cookie + query_strings_config: + query_string_behavior: whitelist + query_strings: + items: + - my-query-string + state: present + +- name: Delete header policy + community.aws.cloudfront_cache_policy: + name: my-cache-policy + state: absent +""" + +RETURN = r""" +cache_policy: + description: The policy's information + returned: success + type: complex + contains: + id: + description: The unique identifier for the cache policy. + returned: always + type: str + sample: 'b2884449-e4de-46a7-ac36-70bc7f1ddd6d' + last_modified_time: + description: The timestamp when the cache policy was last modified. + returned: always + type: str + sample: '2022-02-04T13:23:27.304000+00:00' + cache_policy_config: + description: The cache policy configuration. + returned: always + type: complex + contains: + name: + description: A unique name to identify the cache policy. + type: str + returned: always + sample: my-cache-policy + comment: + description: A comment to describe the cache policy. + type: str + returned: always + sample: My cache policy for my CloudFront distribution + default_ttl: + description: The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + type: int + returned: always + sample: 86400 + min_ttl: + description: The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + type: int + returned: always + sample: 1 + max_ttl: + description: The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + type: int + returned: always + sample: 31536000 + parameters_in_cache_key_and_forwarded_to_origin + description: + - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) + required: false + default: {} + type: dict + suboptions: + enable_accept_encoding_gzip: + description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + type: bool + required: true + enable_accept_encoding_brotli: + description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + type: bool + required: true + headers_config: + description: + - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) + type: dict + required: true + suboptions: + header_behavior: + description: Determines whether any HTTP headers are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist'] + type: str + required: true + headers: + description: + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + type: list + elements: str + required: false + cookies_config: + description: + - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) + required: true + type: dict + suboptions: + cookie_behavior: + description: Determines whether any cookies in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + required: true + type: str + cookies: + description: + - Contains a list of cookie names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + type: list + elements: str + required: false + query_strings_config: + description: + - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) + required: true + type: dict + suboptions: + query_string_behavior: + description: Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + required: true + type: str + query_strings: + description: + - Contains the specific query strings in viewer requests that either are or are not included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + type: list + elements: str + required: false +""" + +import datetime + +try: + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError +except ImportError: + pass # caught by imported AnsibleAWSModule + +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict + +from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule + + +class CloudfrontCachePolicyService(object): + def __init__(self, module): + self.module = module + self.client = module.client("cloudfront") + self.check_mode = module.check_mode + + def find_cache_policy(self, name): + try: + policies = self.client.list_cache_policies()["CachePolicyList"]["Items"] + + for policy in policies: + if policy["CachePolicy"]["CachePolicyConfig"]["Name"] == name: + policy_id = policy["CachePolicy"]["Id"] + # as the list_ request does not contain the Etag (which we need), we need to do another get_ request here + matching_policy = self.client.get_cache_policy(Id=policy["CachePolicy"]["Id"]) + break + else: + matching_policy = None + + return matching_policy + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Error fetching policy information") + + def create_cache_policy(self, name, comment, default_ttl, min_ttl, max_ttl, parameters_in_cache_key_and_forwarded_to_origin): + parameters_in_cache_key_and_forwarded_to_origin = snake_dict_to_camel_dict(parameters_in_cache_key_and_forwarded_to_origin, capitalize_first=True) + + config = { + "Name": name, + "Comment": comment, + "DefaultTTL": default_ttl, + "MinTTL": min_ttl, + "MaxTTL": max_ttl, + "ParametersInCacheKeyAndForwardedToOrigin": self.insert_quantities(parameters_in_cache_key_and_forwarded_to_origin), + } + + config = {k: v for k, v in config.items() if v} + + matching_policy = self.find_cache_policy(name) + + changed = False + + if self.check_mode: + self.module.exit_json(changed=True, cache_policy=camel_dict_to_snake_dict(config)) + + if matching_policy is None: + try: + result = self.client.create_cache_policy(CachePolicyConfig=config) + changed = True + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Error creating policy") + else: + policy_id = matching_policy["CachePolicy"]["Id"] + etag = matching_policy["ETag"] + try: + result = self.client.update_cache_policy( + Id=policy_id, IfMatch=etag, CachePolicyConfig=config + ) + + changed_time = result["CachePolicy"]["LastModifiedTime"] + seconds = 3 # threshhold for returned timestamp age + seconds_ago = datetime.datetime.now(changed_time.tzinfo) - datetime.timedelta(0, seconds) + + # consider change made by this execution of the module if returned timestamp was very recent + if changed_time > seconds_ago: + changed = True + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Updating creating policy") + + self.module.exit_json(changed=changed, **camel_dict_to_snake_dict(result)) + + def delete_cache_policy(self, name): + matching_policy = self.find_cache_policy(name) + + if matching_policy is None: + self.module.exit_json(msg="Didn't find a matching policy by that name, not deleting") + else: + policy_id = matching_policy["CachePolicy"]["Id"] + etag = matching_policy["ETag"] + if self.check_mode: + result = {} + else: + try: + result = self.client.delete_cache_policy(Id=policy_id, IfMatch=etag) + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Error deleting policy") + + self.module.exit_json(changed=True, **camel_dict_to_snake_dict(result)) + + # Inserts a Quantity field into dicts with a list ('Items') + # Implementation from cloudfront_response_headers_policy.py + @staticmethod + def insert_quantities(dict_with_items): + # Items on top level case + if "Items" in dict_with_items and isinstance(dict_with_items["Items"], list): + dict_with_items["Quantity"] = len(dict_with_items["Items"]) + + # Items on second level case + for k, v in dict_with_items.items(): + if isinstance(v, dict) and "Items" in v: + v["Quantity"] = len(v["Items"]) + + return dict_with_items + +def main(): + argument_spec = dict( + name=dict(required=True, type="str"), + comment=dict(type="str"), + default_ttl=dict(type="int"), + min_ttl=dict(required=True, type="int"), + max_ttl=dict(type="int"), + parameters_in_cache_key_and_forwarded_to_origin=dict(type="dict", default=dict()), + state=dict(choices=["present", "absent"], type="str", default="present"), + ) + + module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) + + name = module.params.get("name") + comment = module.params.get("comment", "") + default_ttl = module.params.get("default_ttl") + min_ttl = module.params.get("min_ttl") + max_ttl = module.params.get("max_ttl") + parameters_in_cache_key_and_forwarded_to_origin = module.params.get("parameters_in_cache_key_and_forwarded_to_origin") + state = module.params.get("state") + + service = CloudfrontCachePolicyService(module) + + if state == "absent": + service.delete_cache_policy(name) + else: + service.create_cache_policy( + name, comment, default_ttl, min_ttl, max_ttl, parameters_in_cache_key_and_forwarded_to_origin + ) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/tests/integration/targets/cloudfront_cache_policy/aliases b/tests/integration/targets/cloudfront_cache_policy/aliases new file mode 100644 index 00000000000..4ef4b2067d0 --- /dev/null +++ b/tests/integration/targets/cloudfront_cache_policy/aliases @@ -0,0 +1 @@ +cloud/aws diff --git a/tests/integration/targets/cloudfront_cache_policy/meta/main.yml b/tests/integration/targets/cloudfront_cache_policy/meta/main.yml new file mode 100644 index 00000000000..32cf5dda7ed --- /dev/null +++ b/tests/integration/targets/cloudfront_cache_policy/meta/main.yml @@ -0,0 +1 @@ +dependencies: [] diff --git a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml new file mode 100644 index 00000000000..76d2b19f32f --- /dev/null +++ b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml @@ -0,0 +1,119 @@ +--- + +- name: Integration testing for the cloudfront_cache_policy module + module_defaults: + group/aws: + aws_access_key: '{{ aws_access_key }}' + aws_secret_key: '{{ aws_secret_key }}' + security_token: '{{ security_token | default(omit) }}' + region: '{{ aws_region }}' + block: + + - name: Create a simple cache policy + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-header-policy" + comment: Created by Ansible test + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: false + enable_accept_encoding_brotli: false + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + register: create_result + + - name: Assert creation without errors and return values + assert: + that: + - create_result is changed + - create_result is not failed + - create_result.cache_policy.cache_policy_config.name == "{{ resource_prefix }}-my-header-policy" + + - name: Rerun same task to ensure idempotence + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-header-policy" + comment: Created by Ansible test + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: false + enable_accept_encoding_brotli: false + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + register: rerun_result + + - name: Assert no change and no errors + assert: + that: + - rerun_result is not changed + - rerun_result is not failed + + - name: Update existing policy with more complicated configuration + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-header-policy" + comment: Created by Ansible test + default_ttl: 86400 + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: true + enable_accept_encoding_brotli: true + headers_config: + header_behavior: whitelist + headers: + items: + - accept + - accept-language + - host + - user-agent + cookies_config: + cookie_behavior: whitelist + cookies: + items: + - my-cookie + query_strings_config: + query_string_behavior: whitelist + query_strings: + items: + - my-query-string + state: present + register: update_result + + - name: Assert update and updated return values + assert: + that: + - update_result is changed + - update_result.cache_policy.cache_policy_config.cors_config.parameters_in_cache_key_and_forwarded_to_origin.enable_accept_encoding_gzip == true + - update_result.cache_policy.cache_policy_config.cors_config.parameters_in_cache_key_and_forwarded_to_origin.enable_accept_encoding_brotli == true + + - name: Ensure policy is deleted + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-header-policy" + comment: Created by Ansible test + state: absent + register: delete_result + + - name: Assert deletion without errors + assert: + that: + - delete_result is changed + - delete_result is not failed + - update_result.cache_policy is undefined + + always: + + - name: Ensure policy is deleted + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-header-policy" + state: absent + ignore_errors: true \ No newline at end of file From 3e5e53c82794002dc9d6b2749dbd295f638af997 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 9 Jan 2024 16:08:11 -0800 Subject: [PATCH 03/70] New Module: cloudfront_cache_policy --- plugins/modules/cloudfront_cache_policy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 03213f5e524..85f63e5314d 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -9,10 +9,10 @@ version_added: 7.2.0 module: cloudfront_cache_policy -short_description: Create, update and delete cache policies to be used in a Cloudfront distribution +short_description: Create, update and delete cache policies to be used in a Cloudfront distribution's cache behavior description: - - Create, update and delete cache policies to be used in a Cloudfront distribution for configurating the cache key as well as the default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache + - Create, update and delete cache policies to be used in a Cloudfront distribution's cache behavior for configurating the cache key as well as the default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache. - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_cache_policy.html) author: From 6239cf7178c279257bb8427471199acab4349286 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 9 Jan 2024 16:35:09 -0800 Subject: [PATCH 04/70] New Module: cloudfront_cache_policy --- .../targets/cloudfront_cache_policy/tasks/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml index 76d2b19f32f..46d7d1ce3f2 100644 --- a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml @@ -11,7 +11,7 @@ - name: Create a simple cache policy cloudfront_cache_policy: - name: "{{ resource_prefix }}-my-header-policy" + name: "{{ resource_prefix }}-my-cache-policy" comment: Created by Ansible test min_ttl: 1 max_ttl: 31536000 @@ -36,7 +36,7 @@ - name: Rerun same task to ensure idempotence cloudfront_cache_policy: - name: "{{ resource_prefix }}-my-header-policy" + name: "{{ resource_prefix }}-my-cache-policy" comment: Created by Ansible test min_ttl: 1 max_ttl: 31536000 @@ -60,7 +60,7 @@ - name: Update existing policy with more complicated configuration cloudfront_cache_policy: - name: "{{ resource_prefix }}-my-header-policy" + name: "{{ resource_prefix }}-my-cache-policy" comment: Created by Ansible test default_ttl: 86400 min_ttl: 1 @@ -98,7 +98,7 @@ - name: Ensure policy is deleted cloudfront_cache_policy: - name: "{{ resource_prefix }}-my-header-policy" + name: "{{ resource_prefix }}-my-cache-policy" comment: Created by Ansible test state: absent register: delete_result @@ -114,6 +114,6 @@ - name: Ensure policy is deleted cloudfront_cache_policy: - name: "{{ resource_prefix }}-my-header-policy" + name: "{{ resource_prefix }}-my-cache-policy" state: absent ignore_errors: true \ No newline at end of file From 79a883f3af024fea23c1b2eb45ba173c71b6fd10 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 9 Jan 2024 16:35:53 -0800 Subject: [PATCH 05/70] New Module: cloudfront_cache_policy --- .../integration/targets/cloudfront_cache_policy/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml index 46d7d1ce3f2..b329c5fdcee 100644 --- a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml @@ -32,7 +32,7 @@ that: - create_result is changed - create_result is not failed - - create_result.cache_policy.cache_policy_config.name == "{{ resource_prefix }}-my-header-policy" + - create_result.cache_policy.cache_policy_config.name == "{{ resource_prefix }}-my-cache-policy" - name: Rerun same task to ensure idempotence cloudfront_cache_policy: From 07d8d8c94d26dbcfda01633db31615e1e558a3f8 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 9 Jan 2024 16:38:05 -0800 Subject: [PATCH 06/70] New Module: cloudfront_cache_policy --- .../targets/cloudfront_cache_policy/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml index b329c5fdcee..4b17db2a7c2 100644 --- a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml @@ -93,8 +93,8 @@ assert: that: - update_result is changed - - update_result.cache_policy.cache_policy_config.cors_config.parameters_in_cache_key_and_forwarded_to_origin.enable_accept_encoding_gzip == true - - update_result.cache_policy.cache_policy_config.cors_config.parameters_in_cache_key_and_forwarded_to_origin.enable_accept_encoding_brotli == true + - update_result.cache_policy.cache_policy_config.parameters_in_cache_key_and_forwarded_to_origin.enable_accept_encoding_gzip == true + - update_result.cache_policy.cache_policy_config.parameters_in_cache_key_and_forwarded_to_origin.enable_accept_encoding_brotli == true - name: Ensure policy is deleted cloudfront_cache_policy: From 8e0dbfc0ad33fd0eaaefd0c6c469d7b1b1f697e4 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 9 Jan 2024 16:41:32 -0800 Subject: [PATCH 07/70] New Module: cloudfront_origin_request_policy --- meta/runtime.yml | 1 + .../cloudfront_origin_request_policy.py | 377 ++++++++++++++++++ .../cloudfront_origin_request_policy/aliases | 1 + .../meta/main.yml | 1 + .../tasks/main.yml | 103 +++++ 5 files changed, 483 insertions(+) create mode 100644 plugins/modules/cloudfront_origin_request_policy.py create mode 100644 tests/integration/targets/cloudfront_origin_request_policy/aliases create mode 100644 tests/integration/targets/cloudfront_origin_request_policy/meta/main.yml create mode 100644 tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml diff --git a/meta/runtime.yml b/meta/runtime.yml index c24f616b885..17aee445f5a 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -72,6 +72,7 @@ action_groups: - cloudfront_info - cloudfront_invalidation - cloudfront_origin_access_identity + - cloudfront_origin_request_policy - cloudfront_response_headers_policy - codebuild_project - codecommit_repository diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py new file mode 100644 index 00000000000..44d55ba573b --- /dev/null +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -0,0 +1,377 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2024 Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +DOCUMENTATION = r""" +--- +version_added: 7.2.0 +module: cloudfront_origin_request_policy + +short_description: Create, update and delete origin request policies to be used in a Cloudfront distribution's cache behavior + +description: + - Create, update and delete origin request policies to be used in a Cloudfront distribution's cache behavior for determining the values that CloudFront includes in requests that it sends to the origin. + - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_origin_request_policy.html) + +author: + - Zac Lovoy (@zwlovoy) + +options: + state: + description: Decides if the named policy should be absent or present. + choices: + - present + - absent + default: present + type: str + name: + description: A unique name to identify the origin request policy. + required: true + type: str + comment: + description: A comment to describe the origin request policy. The comment cannot be longer than 128 characters. + required: false + type: str + headers_config: + description: + - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) + type: dict + required: true + suboptions: + header_behavior: + description: Determines whether any HTTP headers are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allViewer', 'allViewerAndWhitelistCloudFront', 'allExcept'] + type: str + required: true + headers: + description: + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + type: list + elements: str + required: false + cookies_config: + description: + - The cookies from viewer requests to include in origin requests. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) + type: dict + required: true + suboptions: + cookie_behavior: + description: Determines whether cookies in viewer requests are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'all', 'allExcept'] + type: str + required: true + cookies: + description: + - Contains a list of cookie names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + type: list + elements: str + required: false + query_strings_config: + description: + - The URL query strings from viewer requests to include in origin requests. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) + required: true + type: dict + suboptions: + query_string_behavior: + description: Determines whether any URL query strings in viewer requests are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'all', 'allExcept'] + type: str + required: true + query_strings: + description: + - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + type: list + elements: str + required: false + +extends_documentation_fragment: + - amazon.aws.common.modules + - amazon.aws.region.modules + - amazon.aws.boto3 +""" + +EXAMPLES = r""" +- name: Creating a basic CloudFront origin request policy with required fields for demonstration + community.aws.cloudfront_origin_request_policy: + name: my-origin-request-policy + comment: My origin request policy for my CloudFront distribution + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + +- name: Creating a CloudFront origin request policy using all predefined properties for demonstration + community.aws.cloudfront_origin_request_policy: + name: my-origin-request-policy + comment: My origin request policy for my CloudFront distribution + headers_config: + header_behavior: whitelist + headers: + items: + - accept + - accept-language + - host + - user-agent + cookies_config: + cookie_behavior: whitelist + cookies: + items: + - my-cookie + query_strings_config: + query_string_behavior: whitelist + query_strings: + items: + - my-query-string + state: present + +- name: Delete header policy + community.aws.cloudfront_origin_request_policy: + name: my-origin-request-policy + state: absent +""" + +RETURN = r""" +origin_request_policy: + description: The policy's information + returned: success + type: complex + contains: + id: + description: The unique identifier for the origin request policy. + returned: always + type: str + sample: '216adef6-5c7f-47e4-b989-5492eafa07d3' + last_modified_time: + description: The timestamp when the origin request policy was last modified. + returned: always + type: str + sample: '2022-02-04T13:23:27.304000+00:00' + origin_request_policy_config: + description: The origin request policy configuration. + returned: always + type: complex + contains: + name: + description: A unique name to identify the origin request policy. + required: true + type: str + comment: + description: A comment to describe the origin request policy. The comment cannot be longer than 128 characters. + required: false + type: str + headers_config: + description: + - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) + type: dict + required: true + suboptions: + header_behavior: + description: Determines whether any HTTP headers are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allViewer', 'allViewerAndWhitelistCloudFront', 'allExcept'] + type: str + required: true + headers: + description: + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + type: list + elements: str + required: false + cookies_config: + description: + - The cookies from viewer requests to include in origin requests. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) + type: dict + required: true + suboptions: + cookie_behavior: + description: Determines whether cookies in viewer requests are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'all', 'allExcept'] + type: str + required: true + cookies: + description: + - Contains a list of cookie names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + type: list + elements: str + required: false + query_strings_config: + description: + - The URL query strings from viewer requests to include in origin requests. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) + required: true + type: dict + suboptions: + query_string_behavior: + description: Determines whether any URL query strings in viewer requests are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'all', 'allExcept'] + type: str + required: true + query_strings: + description: + - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + type: list + elements: str + required: false +""" + +import datetime + +try: + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError +except ImportError: + pass # caught by imported AnsibleAWSModule + +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict + +from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule + +class CloudfrontOriginRequestPolicyService(object): + def __init__(self, module): + self.module = module + self.client = module.client("cloudfront") + self.check_mode = module.check_mode + + def find_origin_request_policy(self, name): + try: + policies = self.client.list_origin_request_policies()["OriginRequestPolicyList"]["Items"] + + for policy in policies: + if policy["OriginRequestPolicy"]["OriginRequestPolicyConfig"]["Name"] == name: + policy_id = policy["OriginRequestPolicy"]["Id"] + # as the list_ request does not contain the Etag (which we need), we need to do another get_ request here + matching_policy = self.client.get_origin_request_policy(Id=policy["OriginRequestPolicy"]["Id"]) + break + else: + matching_policy = None + + return matching_policy + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Error fetching policy information") + + def create_origin_request_policy(self, name, comment, headers_config, cookies_config, query_strings_config): + headers_config = snake_dict_to_camel_dict(headers_config, capitalize_first=True) + cookies_config = snake_dict_to_camel_dict(cookies_config, capitalize_first=True) + query_strings_config = snake_dict_to_camel_dict(query_strings_config, capitalize_first=True) + + config = { + "Name": name, + "Comment": comment, + "HeadersConfig": self.insert_quantities(headers_config), + "CookiesConfig": self.insert_quantities(cookies_config), + "QueryStringsConfig": self.insert_quantities(query_strings_config), + } + + config = {k: v for k, v in config.items() if v} + + matching_policy = self.find_origin_request_policy(name) + + changed = False + + if self.check_mode: + self.module.exit_json(changed=True, origin_request_policy=camel_dict_to_snake_dict(config)) + + if matching_policy is None: + try: + result = self.client.create_origin_request_policy(OriginRequestPolicyConfig=config) + changed = True + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Error creating policy") + else: + policy_id = matching_policy["OriginRequestPolicy"]["Id"] + etag = matching_policy["ETag"] + try: + result = self.client.update_origin_request_policy( + Id=policy_id, IfMatch=etag, OriginRequestPolicyConfig=config + ) + + changed_time = result["OriginRequestPolicy"]["LastModifiedTime"] + seconds = 3 # threshhold for returned timestamp age + seconds_ago = datetime.datetime.now(changed_time.tzinfo) - datetime.timedelta(0, seconds) + + # consider change made by this execution of the module if returned timestamp was very recent + if changed_time > seconds_ago: + changed = True + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Updating creating policy") + + self.module.exit_json(changed=changed, **camel_dict_to_snake_dict(result)) + + def delete_origin_request_policy(self, name): + matching_policy = self.find_origin_request_policy(name) + + if matching_policy is None: + self.module.exit_json(msg="Didn't find a matching policy by that name, not deleting") + else: + policy_id = matching_policy["OriginRequestPolicy"]["Id"] + etag = matching_policy["ETag"] + if self.check_mode: + result = {} + else: + try: + result = self.client.delete_origin_request_policy(Id=policy_id, IfMatch=etag) + except (ClientError, BotoCoreError) as e: + self.module.fail_json_aws(e, msg="Error deleting policy") + + self.module.exit_json(changed=True, **camel_dict_to_snake_dict(result)) + + # Inserts a Quantity field into dicts with a list ('Items') + # Implementation from cloudfront_response_headers_policy.py + @staticmethod + def insert_quantities(dict_with_items): + # Items on top level case + if "Items" in dict_with_items and isinstance(dict_with_items["Items"], list): + dict_with_items["Quantity"] = len(dict_with_items["Items"]) + + # Items on second level case + for k, v in dict_with_items.items(): + if isinstance(v, dict) and "Items" in v: + v["Quantity"] = len(v["Items"]) + + return dict_with_items + +def main(): + argument_spec = dict( + name=dict(required=True, type="str"), + comment=dict(type="str"), + headers_config=dict(required=True, type="dict"), + cookies_config=dict(required=True, type="dict"), + query_strings_config=dict(required=True, type="dict"), + ) + + module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) + + name = module.params.get("name") + comment = module.params.get("comment", "") + headers_config = module.params.get("headers_config") + cookies_config = module.params.get("cookies_config") + query_strings_config = module.params.get("query_strings_config") + + service = CloudfrontOriginRequestPolicyService(module) + + if state == "absent": + service.delete_origin_request_policy(name) + else: + service.create_origin_request_policy( + name, comment, headers_config, cookies_config, query_strings_config + ) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/tests/integration/targets/cloudfront_origin_request_policy/aliases b/tests/integration/targets/cloudfront_origin_request_policy/aliases new file mode 100644 index 00000000000..4ef4b2067d0 --- /dev/null +++ b/tests/integration/targets/cloudfront_origin_request_policy/aliases @@ -0,0 +1 @@ +cloud/aws diff --git a/tests/integration/targets/cloudfront_origin_request_policy/meta/main.yml b/tests/integration/targets/cloudfront_origin_request_policy/meta/main.yml new file mode 100644 index 00000000000..32cf5dda7ed --- /dev/null +++ b/tests/integration/targets/cloudfront_origin_request_policy/meta/main.yml @@ -0,0 +1 @@ +dependencies: [] diff --git a/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml b/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml new file mode 100644 index 00000000000..05a58c2a062 --- /dev/null +++ b/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml @@ -0,0 +1,103 @@ +--- + +- name: Integration testing for the cloudfront_origin_request_policy module + module_defaults: + group/aws: + aws_access_key: '{{ aws_access_key }}' + aws_secret_key: '{{ aws_secret_key }}' + security_token: '{{ security_token | default(omit) }}' + region: '{{ aws_region }}' + block: + + - name: Create a simple origin request policy + cloudfront_origin_request_policy: + name: "{{ resource_prefix }}-my-origin-request-policy" + comment: Created by Ansible test + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + register: create_result + + - name: Assert creation without errors and return values + assert: + that: + - create_result is changed + - create_result is not failed + - create_result.origin_request_policy.origin_request_policy_config.name == "{{ resource_prefix }}-my-origin-request-policy" + + - name: Rerun same task to ensure idempotence + cloudfront_origin_request_policy: + name: "{{ resource_prefix }}-my-origin-request-policy" + comment: Created by Ansible test + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + register: rerun_result + + - name: Assert no change and no errors + assert: + that: + - rerun_result is not changed + - rerun_result is not failed + + - name: Update existing policy with more complicated configuration + cloudfront_origin_request_policy: + name: "{{ resource_prefix }}-my-origin-request-policy" + comment: Created by Ansible test + headers_config: + header_behavior: whitelist + headers: + items: + - accept + - accept-language + - host + - user-agent + cookies_config: + cookie_behavior: whitelist + cookies: + items: + - my-cookie + query_strings_config: + query_string_behavior: whitelist + query_strings: + items: + - my-query-string + state: present + register: update_result + + - name: Assert update and updated return values + assert: + that: + - update_result is changed + - update_result.origin_request_policy.origin_request_policy_config.headers_config.header_behavior == 'whitelist' + - update_result.origin_request_policy.origin_request_policy_config.cookies_config.cookie_behavior == 'whitelist' + + - name: Ensure policy is deleted + cloudfront_origin_request_policy: + name: "{{ resource_prefix }}-my-origin-request-policy" + comment: Created by Ansible test + state: absent + register: delete_result + + - name: Assert deletion without errors + assert: + that: + - delete_result is changed + - delete_result is not failed + - update_result.origin_request_policy is undefined + + always: + + - name: Ensure policy is deleted + cloudfront_origin_request_policy: + name: "{{ resource_prefix }}-my-origin-request-policy" + state: absent + ignore_errors: true \ No newline at end of file From 2135acfa1fa4962706fbaf48247a7166880254c5 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 14:46:30 -0800 Subject: [PATCH 08/70] cloudfront_origin_request_policy: Fixed documentation spacing --- plugins/modules/cloudfront_origin_request_policy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 44d55ba573b..d6f4893d012 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -166,11 +166,11 @@ description: A unique name to identify the origin request policy. required: true type: str - comment: + comment: description: A comment to describe the origin request policy. The comment cannot be longer than 128 characters. required: false type: str - headers_config: + headers_config: description: - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) @@ -189,7 +189,7 @@ type: list elements: str required: false - cookies_config: + cookies_config: description: - The cookies from viewer requests to include in origin requests. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) @@ -208,7 +208,7 @@ type: list elements: str required: false - query_strings_config: + query_strings_config: description: - The URL query strings from viewer requests to include in origin requests. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) From 1410d2236337eb7688172a1381e169e3dfcc34f0 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 14:49:00 -0800 Subject: [PATCH 09/70] cloudfront_cache_policy: Fixed documentation spacing --- plugins/modules/cloudfront_cache_policy.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 85f63e5314d..5e8577eb264 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -233,15 +233,15 @@ default: {} type: dict suboptions: - enable_accept_encoding_gzip: + enable_accept_encoding_gzip: description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. type: bool required: true - enable_accept_encoding_brotli: + enable_accept_encoding_brotli: description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. type: bool required: true - headers_config: + headers_config: description: - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) @@ -260,38 +260,38 @@ type: list elements: str required: false - cookies_config: + cookies_config: description: - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) required: true type: dict suboptions: - cookie_behavior: + cookie_behavior: description: Determines whether any cookies in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allExcept', 'all'] required: true type: str - cookies: + cookies: description: - Contains a list of cookie names. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) type: list elements: str required: false - query_strings_config: + query_strings_config: description: - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) required: true type: dict suboptions: - query_string_behavior: + query_string_behavior: description: Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allExcept', 'all'] required: true type: str - query_strings: + query_strings: description: - Contains the specific query strings in viewer requests that either are or are not included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) From 98c6aa50bea4523863a3959c0e745e3be5451608 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 14:57:30 -0800 Subject: [PATCH 10/70] cloudfront_cache_policy: Fixed documentation spacing --- plugins/modules/cloudfront_cache_policy.py | 40 ++++++++-------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 5e8577eb264..39fa3dc7a12 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -227,77 +227,65 @@ sample: 31536000 parameters_in_cache_key_and_forwarded_to_origin description: - - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) - required: false + - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) default: {} type: dict suboptions: enable_accept_encoding_gzip: description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. type: bool - required: true enable_accept_encoding_brotli: description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. type: bool - required: true headers_config: description: - - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) + - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) type: dict - required: true suboptions: - header_behavior: + header_behavior: description: Determines whether any HTTP headers are included in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist'] type: str - required: true - headers: + headers: description: - - Contains a list of HTTP header names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) type: list elements: str - required: false cookies_config: description: - - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) - required: true + - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) type: dict suboptions: cookie_behavior: description: Determines whether any cookies in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allExcept', 'all'] - required: true type: str cookies: description: - - Contains a list of cookie names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + - Contains a list of cookie names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) type: list elements: str - required: false query_strings_config: description: - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) - required: true type: dict suboptions: query_string_behavior: description: Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allExcept', 'all'] - required: true type: str query_strings: description: - - Contains the specific query strings in viewer requests that either are or are not included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + - Contains the specific query strings in viewer requests that either are or are not included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) type: list elements: str - required: false """ import datetime From 96b6462b1b10855fe0600e60463d33902458e4a1 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 14:57:37 -0800 Subject: [PATCH 11/70] cloudfront_origin_request_policy: Fixed documentation spacing --- .../cloudfront_origin_request_policy.py | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index d6f4893d012..04400027e37 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -164,69 +164,59 @@ contains: name: description: A unique name to identify the origin request policy. - required: true type: str comment: description: A comment to describe the origin request policy. The comment cannot be longer than 128 characters. - required: false type: str headers_config: description: - - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) + - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) type: dict - required: true suboptions: - header_behavior: + header_behavior: description: Determines whether any HTTP headers are included in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allViewer', 'allViewerAndWhitelistCloudFront', 'allExcept'] type: str - required: true - headers: + headers: description: - - Contains a list of HTTP header names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) type: list elements: str - required: false cookies_config: description: - - The cookies from viewer requests to include in origin requests. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) + - The cookies from viewer requests to include in origin requests. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) type: dict - required: true suboptions: - cookie_behavior: + cookie_behavior: description: Determines whether cookies in viewer requests are included in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'all', 'allExcept'] type: str - required: true - cookies: + cookies: description: - - Contains a list of cookie names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + - Contains a list of cookie names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) type: list elements: str - required: false query_strings_config: description: - - The URL query strings from viewer requests to include in origin requests. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) - required: true + - The URL query strings from viewer requests to include in origin requests. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) type: dict suboptions: - query_string_behavior: + query_string_behavior: description: Determines whether any URL query strings in viewer requests are included in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'all', 'allExcept'] type: str required: true - query_strings: + query_strings: description: - - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) type: list elements: str - required: false """ import datetime From 8da255e0fefe0782798435156515084cd1a7f102 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:02:40 -0800 Subject: [PATCH 12/70] cloudfront_cache_policy: Fixed code spacing --- plugins/modules/cloudfront_cache_policy.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 39fa3dc7a12..0b96da53bcf 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -307,7 +307,7 @@ def __init__(self, module): self.module = module self.client = module.client("cloudfront") self.check_mode = module.check_mode - + def find_cache_policy(self, name): try: policies = self.client.list_cache_policies()["CachePolicyList"]["Items"] @@ -404,7 +404,8 @@ def insert_quantities(dict_with_items): v["Quantity"] = len(v["Items"]) return dict_with_items - + + def main(): argument_spec = dict( name=dict(required=True, type="str"), @@ -437,4 +438,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() From ac52b55e2f46e25f93572486a25c50ecae842ee7 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:02:51 -0800 Subject: [PATCH 13/70] cloudfront_origin_request_policy: Fixed code spacing --- plugins/modules/cloudfront_origin_request_policy.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 04400027e37..58dd2c6e033 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -232,12 +232,13 @@ from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule + class CloudfrontOriginRequestPolicyService(object): def __init__(self, module): self.module = module self.client = module.client("cloudfront") self.check_mode = module.check_mode - + def find_origin_request_policy(self, name): try: policies = self.client.list_origin_request_policies()["OriginRequestPolicyList"]["Items"] @@ -335,7 +336,8 @@ def insert_quantities(dict_with_items): v["Quantity"] = len(v["Items"]) return dict_with_items - + + def main(): argument_spec = dict( name=dict(required=True, type="str"), @@ -343,6 +345,7 @@ def main(): headers_config=dict(required=True, type="dict"), cookies_config=dict(required=True, type="dict"), query_strings_config=dict(required=True, type="dict"), + state=dict(choices=["present", "absent"], type="str", default="present"), ) module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) @@ -352,6 +355,7 @@ def main(): headers_config = module.params.get("headers_config") cookies_config = module.params.get("cookies_config") query_strings_config = module.params.get("query_strings_config") + state = module.params.get("state") service = CloudfrontOriginRequestPolicyService(module) @@ -364,4 +368,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() From f14cdcbb46f5530396aadd96af3d9e63b3fa032f Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:09:38 -0800 Subject: [PATCH 14/70] cloudfront_cache_policy: Fixed formatting --- plugins/modules/cloudfront_cache_policy.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 0b96da53bcf..a8a9334f6c2 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -325,8 +325,12 @@ def find_cache_policy(self, name): except (ClientError, BotoCoreError) as e: self.module.fail_json_aws(e, msg="Error fetching policy information") - def create_cache_policy(self, name, comment, default_ttl, min_ttl, max_ttl, parameters_in_cache_key_and_forwarded_to_origin): - parameters_in_cache_key_and_forwarded_to_origin = snake_dict_to_camel_dict(parameters_in_cache_key_and_forwarded_to_origin, capitalize_first=True) + def create_cache_policy( + self, name, comment, default_ttl, min_ttl, max_ttl, parameters_in_cache_key_and_forwarded_to_origin + ): + parameters_in_cache_key_and_forwarded_to_origin = snake_dict_to_camel_dict( + parameters_in_cache_key_and_forwarded_to_origin, capitalize_first=True + ) config = { "Name": name, @@ -334,7 +338,9 @@ def create_cache_policy(self, name, comment, default_ttl, min_ttl, max_ttl, para "DefaultTTL": default_ttl, "MinTTL": min_ttl, "MaxTTL": max_ttl, - "ParametersInCacheKeyAndForwardedToOrigin": self.insert_quantities(parameters_in_cache_key_and_forwarded_to_origin), + "ParametersInCacheKeyAndForwardedToOrigin": self.insert_quantities( + parameters_in_cache_key_and_forwarded_to_origin + ), } config = {k: v for k, v in config.items() if v} @@ -356,9 +362,7 @@ def create_cache_policy(self, name, comment, default_ttl, min_ttl, max_ttl, para policy_id = matching_policy["CachePolicy"]["Id"] etag = matching_policy["ETag"] try: - result = self.client.update_cache_policy( - Id=policy_id, IfMatch=etag, CachePolicyConfig=config - ) + result = self.client.update_cache_policy(Id=policy_id, IfMatch=etag, CachePolicyConfig=config) changed_time = result["CachePolicy"]["LastModifiedTime"] seconds = 3 # threshhold for returned timestamp age @@ -424,7 +428,9 @@ def main(): default_ttl = module.params.get("default_ttl") min_ttl = module.params.get("min_ttl") max_ttl = module.params.get("max_ttl") - parameters_in_cache_key_and_forwarded_to_origin = module.params.get("parameters_in_cache_key_and_forwarded_to_origin") + parameters_in_cache_key_and_forwarded_to_origin = module.params.get( + "parameters_in_cache_key_and_forwarded_to_origin" + ) state = module.params.get("state") service = CloudfrontCachePolicyService(module) From ceee2da5ea411b5fdf7b0dc377029a212c118d38 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:09:47 -0800 Subject: [PATCH 15/70] cloudfront_origin_request_policy: Fixed formatting --- plugins/modules/cloudfront_origin_request_policy.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 58dd2c6e033..464501756e1 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -362,9 +362,7 @@ def main(): if state == "absent": service.delete_origin_request_policy(name) else: - service.create_origin_request_policy( - name, comment, headers_config, cookies_config, query_strings_config - ) + service.create_origin_request_policy(name, comment, headers_config, cookies_config, query_strings_config) if __name__ == "__main__": From 7f574788c21213ef8fc5cecebd083eb2213307ff Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:14:33 -0800 Subject: [PATCH 16/70] cloudfront_cache_policy: Fixed documentation --- plugins/modules/cloudfront_cache_policy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index a8a9334f6c2..696576fed0e 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -46,7 +46,7 @@ description: The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. required: false type: int - parameters_in_cache_key_and_forwarded_to_origin + parameters_in_cache_key_and_forwarded_to_origin: description: - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) @@ -225,7 +225,7 @@ type: int returned: always sample: 31536000 - parameters_in_cache_key_and_forwarded_to_origin + parameters_in_cache_key_and_forwarded_to_origin: description: - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) From d12ac4ad89a43f3c3ebbfc7564567b29b0e32bc8 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:18:26 -0800 Subject: [PATCH 17/70] cloudfront_origin_request_policy: Fixed examples --- plugins/modules/cloudfront_origin_request_policy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 464501756e1..54796bad9e1 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -125,9 +125,9 @@ - user-agent cookies_config: cookie_behavior: whitelist - cookies: - items: - - my-cookie + cookies: + items: + - my-cookie query_strings_config: query_string_behavior: whitelist query_strings: From 424d4b3637ddbc5b820cf0418169ad25f7a9147c Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:23:49 -0800 Subject: [PATCH 18/70] cloudfront_cache_policy: Fixed return values --- plugins/modules/cloudfront_cache_policy.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 696576fed0e..4458da644d5 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -229,9 +229,8 @@ description: - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) - default: {} type: dict - suboptions: + contains: enable_accept_encoding_gzip: description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. type: bool @@ -243,7 +242,7 @@ - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) type: dict - suboptions: + contains: header_behavior: description: Determines whether any HTTP headers are included in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist'] @@ -259,7 +258,7 @@ - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) type: dict - suboptions: + contains: cookie_behavior: description: Determines whether any cookies in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allExcept', 'all'] @@ -275,7 +274,7 @@ - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) type: dict - suboptions: + contains: query_string_behavior: description: Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allExcept', 'all'] From 53f8927ca841628dc55fbe39ab83d7e66c36a82a Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:23:59 -0800 Subject: [PATCH 19/70] cloudfront_origin_request_policy: Fixed return values --- plugins/modules/cloudfront_origin_request_policy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 54796bad9e1..344b150ffa8 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -173,7 +173,7 @@ - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) type: dict - suboptions: + contains: header_behavior: description: Determines whether any HTTP headers are included in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allViewer', 'allViewerAndWhitelistCloudFront', 'allExcept'] @@ -189,7 +189,7 @@ - The cookies from viewer requests to include in origin requests. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) type: dict - suboptions: + contains: cookie_behavior: description: Determines whether cookies in viewer requests are included in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'all', 'allExcept'] @@ -205,7 +205,7 @@ - The URL query strings from viewer requests to include in origin requests. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) type: dict - suboptions: + contains: query_string_behavior: description: Determines whether any URL query strings in viewer requests are included in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'all', 'allExcept'] From 7019f41dfd808cd92a88ca89013debe723a305f1 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:35:30 -0800 Subject: [PATCH 20/70] cloudfront_origin_request_policy: Fixed spacing --- plugins/modules/cloudfront_origin_request_policy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 344b150ffa8..ba6dc7de1b2 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -12,7 +12,8 @@ short_description: Create, update and delete origin request policies to be used in a Cloudfront distribution's cache behavior description: - - Create, update and delete origin request policies to be used in a Cloudfront distribution's cache behavior for determining the values that CloudFront includes in requests that it sends to the origin. + - Create, update and delete origin request policies to be used in a Cloudfront distribution's cache behavior + for determining the values that CloudFront includes in requests that it sends to the origin. - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_origin_request_policy.html) author: @@ -210,7 +211,6 @@ description: Determines whether any URL query strings in viewer requests are included in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'all', 'allExcept'] type: str - required: true query_strings: description: - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. From 9667bfe21ddbc609fdccacc7311984f83518999e Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:35:42 -0800 Subject: [PATCH 21/70] cloudfront_cache_policy: Fixed spacing --- plugins/modules/cloudfront_cache_policy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 4458da644d5..6b3ee04f74f 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -48,10 +48,10 @@ type: int parameters_in_cache_key_and_forwarded_to_origin: description: - - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. + - The HTTP headers, cookies, and URL query strings to include in the cache key. + The values included in the cache key are also included in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) required: false - default: {} type: dict suboptions: enable_accept_encoding_gzip: @@ -416,7 +416,7 @@ def main(): default_ttl=dict(type="int"), min_ttl=dict(required=True, type="int"), max_ttl=dict(type="int"), - parameters_in_cache_key_and_forwarded_to_origin=dict(type="dict", default=dict()), + parameters_in_cache_key_and_forwarded_to_origin=dict(), state=dict(choices=["present", "absent"], type="str", default="present"), ) From 6ab88210930aded12aefe9757583cd9596b02f3d Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:41:44 -0800 Subject: [PATCH 22/70] cloudfront_origin_request_policy: Fixed line lengths --- .../cloudfront_origin_request_policy.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index ba6dc7de1b2..faeb7a37579 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -38,7 +38,8 @@ headers_config: description: - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) type: dict required: true suboptions: @@ -57,7 +58,8 @@ cookies_config: description: - The cookies from viewer requests to include in origin requests. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) type: dict required: true suboptions: @@ -76,7 +78,8 @@ query_strings_config: description: - The URL query strings from viewer requests to include in origin requests. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) required: true type: dict suboptions: @@ -172,7 +175,8 @@ headers_config: description: - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) type: dict contains: header_behavior: @@ -188,7 +192,8 @@ cookies_config: description: - The cookies from viewer requests to include in origin requests. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) type: dict contains: cookie_behavior: @@ -204,7 +209,8 @@ query_strings_config: description: - The URL query strings from viewer requests to include in origin requests. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) type: dict contains: query_string_behavior: @@ -214,7 +220,8 @@ query_strings: description: - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) type: list elements: str """ From 4af9a90599cba673138a72dd56a1848ba20ff0d2 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:45:51 -0800 Subject: [PATCH 23/70] cloudfront_cache_policy: Fixed line lengths --- plugins/modules/cloudfront_cache_policy.py | 122 ++++++++++++++------- 1 file changed, 85 insertions(+), 37 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 6b3ee04f74f..bdde21ba904 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -12,7 +12,8 @@ short_description: Create, update and delete cache policies to be used in a Cloudfront distribution's cache behavior description: - - Create, update and delete cache policies to be used in a Cloudfront distribution's cache behavior for configurating the cache key as well as the default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache. + - Create, update and delete cache policies to be used in a Cloudfront distribution's cache behavior + for configurating the cache key as well as the default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache. - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_cache_policy.html) author: @@ -35,87 +36,114 @@ required: false type: str default_ttl: - description: The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + description: + - The default amount of time, in seconds, that you want objects to stay in the CloudFront cache + before CloudFront sends another request to the origin to see if the object has been updated. required: false type: int min_ttl: - description: The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + description: + - The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before + CloudFront sends another request to the origin to see if the object has been updated. required: true type: int max_ttl: - description: The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + description: + - The maximum amount of time, in seconds, that objects stay in the CloudFront cache before + CloudFront sends another request to the origin to see if the object has been updated. required: false type: int parameters_in_cache_key_and_forwarded_to_origin: description: - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) required: false type: dict suboptions: enable_accept_encoding_gzip: - description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + description: + - A flag that can affect whether the Accept-Encoding HTTP header is included + in the cache key and included in requests that CloudFront sends to the origin. type: bool required: true enable_accept_encoding_brotli: - description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + description: + - A flag that can affect whether the Accept-Encoding HTTP header is included + in the cache key and included in requests that CloudFront sends to the origin. type: bool required: true headers_config: description: - - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) + - An object that determines whether any HTTP headers (and if so, which headers) + are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) type: dict required: true suboptions: header_behavior: - description: Determines whether any HTTP headers are included in the cache key and in requests that CloudFront sends to the origin. + description: + - Determines whether any HTTP headers are included in the cache key + and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist'] type: str required: true headers: description: - Contains a list of HTTP header names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) type: list elements: str required: false cookies_config: description: - - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) + - An object that determines whether any cookies in viewer requests (and if so, which cookies) + are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) required: true type: dict suboptions: cookie_behavior: - description: Determines whether any cookies in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + description: + - Determines whether any cookies in viewer requests are included + in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allExcept', 'all'] required: true type: str cookies: description: - Contains a list of cookie names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) type: list elements: str required: false query_strings_config: description: - - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) + - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) + are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) required: true type: dict suboptions: query_string_behavior: - description: Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + description: + - Determines whether any URL query strings in viewer requests are included + in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allExcept', 'all'] required: true type: str query_strings: description: - - Contains the specific query strings in viewer requests that either are or are not included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + - Contains the specific query strings in viewer requests that either are or are not included + in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) type: list elements: str required: false @@ -227,52 +255,70 @@ sample: 31536000 parameters_in_cache_key_and_forwarded_to_origin: description: - - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) + - The HTTP headers, cookies, and URL query strings to include in the cache key. + The values included in the cache key are also included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) type: dict contains: enable_accept_encoding_gzip: - description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + description: + - A flag that can affect whether the Accept-Encoding HTTP header is included + in the cache key and included in requests that CloudFront sends to the origin. type: bool enable_accept_encoding_brotli: - description: A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin. + description: + - A flag that can affect whether the Accept-Encoding HTTP header is included + in the cache key and included in requests that CloudFront sends to the origin. type: bool headers_config: description: - - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) + - An object that determines whether any HTTP headers (and if so, which headers) are included + in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) type: dict contains: header_behavior: - description: Determines whether any HTTP headers are included in the cache key and in requests that CloudFront sends to the origin. + description: + - Determines whether any HTTP headers are included in the cache key + and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist'] type: str headers: description: - Contains a list of HTTP header names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) type: list elements: str cookies_config: description: - - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) + - An object that determines whether any cookies in viewer requests (and if so, which cookies) + are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) type: dict contains: cookie_behavior: - description: Determines whether any cookies in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + description: + - Determines whether any cookies in viewer requests are included + in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allExcept', 'all'] type: str cookies: description: - Contains a list of cookie names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) type: list elements: str query_strings_config: description: - - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) + - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) + are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) type: dict contains: query_string_behavior: @@ -281,8 +327,10 @@ type: str query_strings: description: - - Contains the specific query strings in viewer requests that either are or are not included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + - Contains the specific query strings in viewer requests that either are or are not included + in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) type: list elements: str """ @@ -416,7 +464,7 @@ def main(): default_ttl=dict(type="int"), min_ttl=dict(required=True, type="int"), max_ttl=dict(type="int"), - parameters_in_cache_key_and_forwarded_to_origin=dict(), + parameters_in_cache_key_and_forwarded_to_origin=dict(type="dict"), state=dict(choices=["present", "absent"], type="str", default="present"), ) From 37416cc8d265b70c67a2d25f94c95537cd6a81d8 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 15:51:32 -0800 Subject: [PATCH 24/70] cloudfront_cache_policy: Fixed line lengths --- plugins/modules/cloudfront_cache_policy.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index bdde21ba904..8496bd231f6 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -12,8 +12,8 @@ short_description: Create, update and delete cache policies to be used in a Cloudfront distribution's cache behavior description: - - Create, update and delete cache policies to be used in a Cloudfront distribution's cache behavior - for configurating the cache key as well as the default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache. + - Create, update and delete cache policies to be used in a Cloudfront distribution's cache behavior for + configurating the cache key as well as the default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache. - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_cache_policy.html) author: @@ -239,17 +239,23 @@ returned: always sample: My cache policy for my CloudFront distribution default_ttl: - description: The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + description: + - The default amount of time, in seconds, that you want objects to stay in the CloudFront cache + before CloudFront sends another request to the origin to see if the object has been updated. type: int returned: always sample: 86400 min_ttl: - description: The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + description: + - The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache + before CloudFront sends another request to the origin to see if the object has been updated. type: int returned: always sample: 1 max_ttl: - description: The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. + description: + - The maximum amount of time, in seconds, that objects stay in the CloudFront cache + before CloudFront sends another request to the origin to see if the object has been updated. type: int returned: always sample: 31536000 @@ -322,7 +328,9 @@ type: dict contains: query_string_behavior: - description: Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + description: + - Determines whether any URL query strings in viewer requests + are included in the cache key and in requests that CloudFront sends to the origin. choices: ['none', 'whitelist', 'allExcept', 'all'] type: str query_strings: @@ -464,7 +472,7 @@ def main(): default_ttl=dict(type="int"), min_ttl=dict(required=True, type="int"), max_ttl=dict(type="int"), - parameters_in_cache_key_and_forwarded_to_origin=dict(type="dict"), + parameters_in_cache_key_and_forwarded_to_origin=dict(type="dict", no_log=False), state=dict(choices=["present", "absent"], type="str", default="present"), ) From f7e651f163e425150df721f80fa40ee023bd83c0 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 16:01:35 -0800 Subject: [PATCH 25/70] cloudfront_cache_policy + cloudfront_origin_request_policy: Added changelog --- ...loudfront_cache_policy-cloudfront_origin_request_policy.yaml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/2046-cloudfront_cache_policy-cloudfront_origin_request_policy.yaml diff --git a/changelogs/fragments/2046-cloudfront_cache_policy-cloudfront_origin_request_policy.yaml b/changelogs/fragments/2046-cloudfront_cache_policy-cloudfront_origin_request_policy.yaml new file mode 100644 index 00000000000..6829cba2360 --- /dev/null +++ b/changelogs/fragments/2046-cloudfront_cache_policy-cloudfront_origin_request_policy.yaml @@ -0,0 +1,2 @@ +minor_changes: + - "Added ``cloudfront_cache_policy`` and ``cloudfront_origin_request_policy`` modules (https://github.com/ansible-collections/community.aws/pull/2046)." \ No newline at end of file From faf6841cdf5754289f239827103e903ecc955598 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 16:41:20 -0800 Subject: [PATCH 26/70] cloudfront_cache_policy: Updated spacing --- plugins/modules/cloudfront_cache_policy.py | 254 ++++++++++----------- 1 file changed, 127 insertions(+), 127 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 8496bd231f6..1bf7cfb259d 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -20,133 +20,133 @@ - Zac Lovoy (@zwlovoy) options: - state: - description: Decides if the named policy should be absent or present. - choices: - - present - - absent - default: present - type: str - name: - description: A unique name to identify the cache policy. - required: true - type: str - comment: - description: A comment to describe the cache policy. The comment cannot be longer than 128 characters. - required: false - type: str - default_ttl: - description: - - The default amount of time, in seconds, that you want objects to stay in the CloudFront cache - before CloudFront sends another request to the origin to see if the object has been updated. - required: false - type: int - min_ttl: - description: - - The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before - CloudFront sends another request to the origin to see if the object has been updated. - required: true - type: int - max_ttl: - description: - - The maximum amount of time, in seconds, that objects stay in the CloudFront cache before - CloudFront sends another request to the origin to see if the object has been updated. - required: false - type: int - parameters_in_cache_key_and_forwarded_to_origin: - description: - - The HTTP headers, cookies, and URL query strings to include in the cache key. - The values included in the cache key are also included in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) - required: false - type: dict - suboptions: - enable_accept_encoding_gzip: - description: - - A flag that can affect whether the Accept-Encoding HTTP header is included - in the cache key and included in requests that CloudFront sends to the origin. - type: bool - required: true - enable_accept_encoding_brotli: - description: - - A flag that can affect whether the Accept-Encoding HTTP header is included - in the cache key and included in requests that CloudFront sends to the origin. - type: bool - required: true - headers_config: - description: - - An object that determines whether any HTTP headers (and if so, which headers) - are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) - type: dict - required: true - suboptions: - header_behavior: - description: - - Determines whether any HTTP headers are included in the cache key - and in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist'] - type: str - required: true - headers: - description: - - Contains a list of HTTP header names. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) - type: list - elements: str - required: false - cookies_config: - description: - - An object that determines whether any cookies in viewer requests (and if so, which cookies) - are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) - required: true - type: dict - suboptions: - cookie_behavior: - description: - - Determines whether any cookies in viewer requests are included - in the cache key and in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist', 'allExcept', 'all'] - required: true - type: str - cookies: - description: - - Contains a list of cookie names. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) - type: list - elements: str - required: false - query_strings_config: - description: - - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) - are included in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) - required: true - type: dict - suboptions: - query_string_behavior: - description: - - Determines whether any URL query strings in viewer requests are included - in the cache key and in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist', 'allExcept', 'all'] - required: true - type: str - query_strings: - description: - - Contains the specific query strings in viewer requests that either are or are not included - in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) - type: list - elements: str - required: false + state: + description: Decides if the named policy should be absent or present. + choices: + - present + - absent + default: present + type: str + name: + description: A unique name to identify the cache policy. + required: true + type: str + comment: + description: A comment to describe the cache policy. The comment cannot be longer than 128 characters. + required: false + type: str + default_ttl: + description: + - The default amount of time, in seconds, that you want objects to stay in the CloudFront cache + before CloudFront sends another request to the origin to see if the object has been updated. + required: false + type: int + min_ttl: + description: + - The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before + CloudFront sends another request to the origin to see if the object has been updated. + required: true + type: int + max_ttl: + description: + - The maximum amount of time, in seconds, that objects stay in the CloudFront cache before + CloudFront sends another request to the origin to see if the object has been updated. + required: false + type: int + parameters_in_cache_key_and_forwarded_to_origin: + description: + - The HTTP headers, cookies, and URL query strings to include in the cache key. + The values included in the cache key are also included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) + required: false + type: dict + suboptions: + enable_accept_encoding_gzip: + description: + - A flag that can affect whether the Accept-Encoding HTTP header is included + in the cache key and included in requests that CloudFront sends to the origin. + type: bool + required: true + enable_accept_encoding_brotli: + description: + - A flag that can affect whether the Accept-Encoding HTTP header is included + in the cache key and included in requests that CloudFront sends to the origin. + type: bool + required: true + headers_config: + description: + - An object that determines whether any HTTP headers (and if so, which headers) + are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) + type: dict + required: true + suboptions: + header_behavior: + description: + - Determines whether any HTTP headers are included in the cache key + and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist'] + type: str + required: true + headers: + description: + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + type: list + elements: str + required: false + cookies_config: + description: + - An object that determines whether any cookies in viewer requests (and if so, which cookies) + are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) + required: true + type: dict + suboptions: + cookie_behavior: + description: + - Determines whether any cookies in viewer requests are included + in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + required: true + type: str + cookies: + description: + - Contains a list of cookie names. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + type: list + elements: str + required: false + query_strings_config: + description: + - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) + are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) + required: true + type: dict + suboptions: + query_string_behavior: + description: + - Determines whether any URL query strings in viewer requests are included + in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + required: true + type: str + query_strings: + description: + - Contains the specific query strings in viewer requests that either are or are not included + in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + type: list + elements: str + required: false extends_documentation_fragment: - amazon.aws.common.modules From e5fea923d59d80d7c184cf9f8d92fd2dd18e4daa Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 16:41:35 -0800 Subject: [PATCH 27/70] cloudfront_origin_request_policy: Updated spacing --- .../cloudfront_origin_request_policy.py | 150 +++++++++--------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index faeb7a37579..1e1fb8ec138 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -20,81 +20,81 @@ - Zac Lovoy (@zwlovoy) options: - state: - description: Decides if the named policy should be absent or present. - choices: - - present - - absent - default: present - type: str - name: - description: A unique name to identify the origin request policy. - required: true - type: str - comment: - description: A comment to describe the origin request policy. The comment cannot be longer than 128 characters. - required: false - type: str - headers_config: - description: - - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) - type: dict - required: true - suboptions: - header_behavior: - description: Determines whether any HTTP headers are included in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist', 'allViewer', 'allViewerAndWhitelistCloudFront', 'allExcept'] - type: str - required: true - headers: - description: - - Contains a list of HTTP header names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) - type: list - elements: str - required: false - cookies_config: - description: - - The cookies from viewer requests to include in origin requests. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) - type: dict - required: true - suboptions: - cookie_behavior: - description: Determines whether cookies in viewer requests are included in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist', 'all', 'allExcept'] - type: str - required: true - cookies: - description: - - Contains a list of cookie names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) - type: list - elements: str - required: false - query_strings_config: - description: - - The URL query strings from viewer requests to include in origin requests. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) - required: true - type: dict - suboptions: - query_string_behavior: - description: Determines whether any URL query strings in viewer requests are included in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist', 'all', 'allExcept'] - type: str - required: true - query_strings: - description: - - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) - type: list - elements: str - required: false + state: + description: Decides if the named policy should be absent or present. + choices: + - present + - absent + default: present + type: str + name: + description: A unique name to identify the origin request policy. + required: true + type: str + comment: + description: A comment to describe the origin request policy. The comment cannot be longer than 128 characters. + required: false + type: str + headers_config: + description: + - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) + type: dict + required: true + suboptions: + header_behavior: + description: Determines whether any HTTP headers are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allViewer', 'allViewerAndWhitelistCloudFront', 'allExcept'] + type: str + required: true + headers: + description: + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + type: list + elements: str + required: false + cookies_config: + description: + - The cookies from viewer requests to include in origin requests. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) + type: dict + required: true + suboptions: + cookie_behavior: + description: Determines whether cookies in viewer requests are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'all', 'allExcept'] + type: str + required: true + cookies: + description: + - Contains a list of cookie names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + type: list + elements: str + required: false + query_strings_config: + description: + - The URL query strings from viewer requests to include in origin requests. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) + required: true + type: dict + suboptions: + query_string_behavior: + description: Determines whether any URL query strings in viewer requests are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'all', 'allExcept'] + type: str + required: true + query_strings: + description: + - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + type: list + elements: str + required: false extends_documentation_fragment: - amazon.aws.common.modules From 76414d349dc58222d699b7a1036ebe1d63e5c6cf Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 16:43:45 -0800 Subject: [PATCH 28/70] cloudfront_origin_request_policy: Updated spacing --- .../cloudfront_origin_request_policy.py | 154 +++++++++--------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 1e1fb8ec138..55da73aed89 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -147,83 +147,83 @@ RETURN = r""" origin_request_policy: - description: The policy's information - returned: success - type: complex - contains: - id: - description: The unique identifier for the origin request policy. - returned: always - type: str - sample: '216adef6-5c7f-47e4-b989-5492eafa07d3' - last_modified_time: - description: The timestamp when the origin request policy was last modified. - returned: always - type: str - sample: '2022-02-04T13:23:27.304000+00:00' - origin_request_policy_config: - description: The origin request policy configuration. - returned: always - type: complex - contains: - name: - description: A unique name to identify the origin request policy. - type: str - comment: - description: A comment to describe the origin request policy. The comment cannot be longer than 128 characters. - type: str - headers_config: - description: - - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) - type: dict - contains: - header_behavior: - description: Determines whether any HTTP headers are included in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist', 'allViewer', 'allViewerAndWhitelistCloudFront', 'allExcept'] - type: str - headers: - description: - - Contains a list of HTTP header names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) - type: list - elements: str - cookies_config: - description: - - The cookies from viewer requests to include in origin requests. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) - type: dict - contains: - cookie_behavior: - description: Determines whether cookies in viewer requests are included in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist', 'all', 'allExcept'] - type: str - cookies: - description: - - Contains a list of cookie names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) - type: list - elements: str - query_strings_config: - description: - - The URL query strings from viewer requests to include in origin requests. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) - type: dict - contains: - query_string_behavior: - description: Determines whether any URL query strings in viewer requests are included in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist', 'all', 'allExcept'] - type: str - query_strings: - description: - - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) - type: list - elements: str + description: The policy's information + returned: success + type: complex + contains: + id: + description: The unique identifier for the origin request policy. + returned: always + type: str + sample: '216adef6-5c7f-47e4-b989-5492eafa07d3' + last_modified_time: + description: The timestamp when the origin request policy was last modified. + returned: always + type: str + sample: '2022-02-04T13:23:27.304000+00:00' + origin_request_policy_config: + description: The origin request policy configuration. + returned: always + type: complex + contains: + name: + description: A unique name to identify the origin request policy. + type: str + comment: + description: A comment to describe the origin request policy. The comment cannot be longer than 128 characters. + type: str + headers_config: + description: + - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) + type: dict + contains: + header_behavior: + description: Determines whether any HTTP headers are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allViewer', 'allViewerAndWhitelistCloudFront', 'allExcept'] + type: str + headers: + description: + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + type: list + elements: str + cookies_config: + description: + - The cookies from viewer requests to include in origin requests. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) + type: dict + contains: + cookie_behavior: + description: Determines whether cookies in viewer requests are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'all', 'allExcept'] + type: str + cookies: + description: + - Contains a list of cookie names. + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + type: list + elements: str + query_strings_config: + description: + - The URL query strings from viewer requests to include in origin requests. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) + type: dict + contains: + query_string_behavior: + description: Determines whether any URL query strings in viewer requests are included in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'all', 'allExcept'] + type: str + query_strings: + description: + - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + type: list + elements: str """ import datetime From bab83bae58d13b557ab295105a86e7b07e0d3336 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 16:43:59 -0800 Subject: [PATCH 29/70] cloudfront_cache_policy: Updated spacing --- plugins/modules/cloudfront_cache_policy.py | 256 ++++++++++----------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 1bf7cfb259d..a3187335ed7 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -209,138 +209,138 @@ RETURN = r""" cache_policy: - description: The policy's information - returned: success - type: complex - contains: - id: - description: The unique identifier for the cache policy. - returned: always - type: str - sample: 'b2884449-e4de-46a7-ac36-70bc7f1ddd6d' - last_modified_time: - description: The timestamp when the cache policy was last modified. - returned: always - type: str - sample: '2022-02-04T13:23:27.304000+00:00' - cache_policy_config: - description: The cache policy configuration. - returned: always - type: complex - contains: - name: - description: A unique name to identify the cache policy. - type: str - returned: always - sample: my-cache-policy - comment: - description: A comment to describe the cache policy. - type: str - returned: always - sample: My cache policy for my CloudFront distribution - default_ttl: - description: - - The default amount of time, in seconds, that you want objects to stay in the CloudFront cache - before CloudFront sends another request to the origin to see if the object has been updated. - type: int - returned: always - sample: 86400 - min_ttl: - description: - - The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache - before CloudFront sends another request to the origin to see if the object has been updated. - type: int - returned: always - sample: 1 - max_ttl: - description: - - The maximum amount of time, in seconds, that objects stay in the CloudFront cache - before CloudFront sends another request to the origin to see if the object has been updated. - type: int - returned: always - sample: 31536000 - parameters_in_cache_key_and_forwarded_to_origin: - description: - - The HTTP headers, cookies, and URL query strings to include in the cache key. - The values included in the cache key are also included in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) - type: dict - contains: - enable_accept_encoding_gzip: - description: - - A flag that can affect whether the Accept-Encoding HTTP header is included - in the cache key and included in requests that CloudFront sends to the origin. - type: bool - enable_accept_encoding_brotli: - description: - - A flag that can affect whether the Accept-Encoding HTTP header is included - in the cache key and included in requests that CloudFront sends to the origin. - type: bool - headers_config: - description: - - An object that determines whether any HTTP headers (and if so, which headers) are included - in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) - type: dict - contains: - header_behavior: - description: - - Determines whether any HTTP headers are included in the cache key - and in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist'] - type: str - headers: - description: - - Contains a list of HTTP header names. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) - type: list - elements: str - cookies_config: - description: - - An object that determines whether any cookies in viewer requests (and if so, which cookies) + description: The policy's information + returned: success + type: complex + contains: + id: + description: The unique identifier for the cache policy. + returned: always + type: str + sample: 'b2884449-e4de-46a7-ac36-70bc7f1ddd6d' + last_modified_time: + description: The timestamp when the cache policy was last modified. + returned: always + type: str + sample: '2022-02-04T13:23:27.304000+00:00' + cache_policy_config: + description: The cache policy configuration. + returned: always + type: complex + contains: + name: + description: A unique name to identify the cache policy. + type: str + returned: always + sample: my-cache-policy + comment: + description: A comment to describe the cache policy. + type: str + returned: always + sample: My cache policy for my CloudFront distribution + default_ttl: + description: + - The default amount of time, in seconds, that you want objects to stay in the CloudFront cache + before CloudFront sends another request to the origin to see if the object has been updated. + type: int + returned: always + sample: 86400 + min_ttl: + description: + - The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache + before CloudFront sends another request to the origin to see if the object has been updated. + type: int + returned: always + sample: 1 + max_ttl: + description: + - The maximum amount of time, in seconds, that objects stay in the CloudFront cache + before CloudFront sends another request to the origin to see if the object has been updated. + type: int + returned: always + sample: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + description: + - The HTTP headers, cookies, and URL query strings to include in the cache key. + The values included in the cache key are also included in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) + type: dict + contains: + enable_accept_encoding_gzip: + description: + - A flag that can affect whether the Accept-Encoding HTTP header is included + in the cache key and included in requests that CloudFront sends to the origin. + type: bool + enable_accept_encoding_brotli: + description: + - A flag that can affect whether the Accept-Encoding HTTP header is included + in the cache key and included in requests that CloudFront sends to the origin. + type: bool + headers_config: + description: + - An object that determines whether any HTTP headers (and if so, which headers) are included + in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) + type: dict + contains: + header_behavior: + description: + - Determines whether any HTTP headers are included in the cache key + and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist'] + type: str + headers: + description: + - Contains a list of HTTP header names. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + type: list + elements: str + cookies_config: + description: + - An object that determines whether any cookies in viewer requests (and if so, which cookies) + are included in the cache key and in requests that CloudFront sends to the origin. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) + type: dict + contains: + cookie_behavior: + description: + - Determines whether any cookies in viewer requests are included + in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + type: str + cookies: + description: + - Contains a list of cookie names. + - For more information see the CloudFront documentation at + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + type: list + elements: str + query_strings_config: + description: + - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) - type: dict - contains: - cookie_behavior: - description: - - Determines whether any cookies in viewer requests are included - in the cache key and in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist', 'allExcept', 'all'] - type: str - cookies: - description: - - Contains a list of cookie names. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) - type: list - elements: str - query_strings_config: - description: - - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) + type: dict + contains: + query_string_behavior: + description: + - Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. + choices: ['none', 'whitelist', 'allExcept', 'all'] + type: str + query_strings: + description: + - Contains the specific query strings in viewer requests that either are or are not included + in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) - type: dict - contains: - query_string_behavior: - description: - - Determines whether any URL query strings in viewer requests - are included in the cache key and in requests that CloudFront sends to the origin. - choices: ['none', 'whitelist', 'allExcept', 'all'] - type: str - query_strings: - description: - - Contains the specific query strings in viewer requests that either are or are not included - in the cache key and in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) - type: list - elements: str + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + type: list + elements: str """ import datetime From e343e466bfd02a665cac67d0a081c872eb3d8ee0 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 21:03:16 -0800 Subject: [PATCH 30/70] cloudfront_cache_policy: Fixed property permissions to support deleting policy --- plugins/modules/cloudfront_cache_policy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index a3187335ed7..970524e548c 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -45,7 +45,7 @@ description: - The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. - required: true + required: false type: int max_ttl: description: @@ -470,7 +470,7 @@ def main(): name=dict(required=True, type="str"), comment=dict(type="str"), default_ttl=dict(type="int"), - min_ttl=dict(required=True, type="int"), + min_ttl=dict(type="int"), max_ttl=dict(type="int"), parameters_in_cache_key_and_forwarded_to_origin=dict(type="dict", no_log=False), state=dict(choices=["present", "absent"], type="str", default="present"), From e32092da2adb304adff057549ad4d0c6de292744 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Tue, 16 Jan 2024 21:03:39 -0800 Subject: [PATCH 31/70] cloudfront_origin_request_policy: Fixed property permissions to support deleting policy --- plugins/modules/cloudfront_origin_request_policy.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 55da73aed89..2045795e671 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -41,7 +41,7 @@ - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) type: dict - required: true + required: false suboptions: header_behavior: description: Determines whether any HTTP headers are included in requests that CloudFront sends to the origin. @@ -61,7 +61,7 @@ - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) type: dict - required: true + required: false suboptions: cookie_behavior: description: Determines whether cookies in viewer requests are included in requests that CloudFront sends to the origin. @@ -80,7 +80,7 @@ - The URL query strings from viewer requests to include in origin requests. - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) - required: true + required: false type: dict suboptions: query_string_behavior: @@ -349,9 +349,9 @@ def main(): argument_spec = dict( name=dict(required=True, type="str"), comment=dict(type="str"), - headers_config=dict(required=True, type="dict"), - cookies_config=dict(required=True, type="dict"), - query_strings_config=dict(required=True, type="dict"), + headers_config=dict(type="dict"), + cookies_config=dict(type="dict"), + query_strings_config=dict(type="dict"), state=dict(choices=["present", "absent"], type="str", default="present"), ) From 50a9021bf7e0b399e619bf6fb9711598847f2cf9 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Wed, 17 Jan 2024 09:10:56 -0800 Subject: [PATCH 32/70] cloudfront_cache_policy: Added filter to list function to make it more efficient --- plugins/modules/cloudfront_cache_policy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 970524e548c..0c8a3a7a7cd 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -365,7 +365,8 @@ def __init__(self, module): def find_cache_policy(self, name): try: - policies = self.client.list_cache_policies()["CachePolicyList"]["Items"] + # We only get the custom policies to make the query more efficient + policies = self.client.list_cache_policies(Type="custom")["CachePolicyList"]["Items"] for policy in policies: if policy["CachePolicy"]["CachePolicyConfig"]["Name"] == name: From 56da3d0f473fe224698e97384667d43af509bc9f Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Wed, 17 Jan 2024 09:11:11 -0800 Subject: [PATCH 33/70] cloudfront_origin_request_policy: Added filter to list function to make it more efficient --- plugins/modules/cloudfront_origin_request_policy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 2045795e671..8e86a11e170 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -248,7 +248,8 @@ def __init__(self, module): def find_origin_request_policy(self, name): try: - policies = self.client.list_origin_request_policies()["OriginRequestPolicyList"]["Items"] + # We only get the custom policies to make the query more efficient + policies = self.client.list_origin_request_policies(Type="custom")["OriginRequestPolicyList"]["Items"] for policy in policies: if policy["OriginRequestPolicy"]["OriginRequestPolicyConfig"]["Name"] == name: From 8b6d180194e98f86b18c5ee45a6b94cfc53f2a70 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Wed, 17 Jan 2024 10:10:18 -0800 Subject: [PATCH 34/70] cloudfront_cache_policy: Fixed spacing on integration test --- .../integration/targets/cloudfront_cache_policy/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml index 4b17db2a7c2..96ce180bca8 100644 --- a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml @@ -116,4 +116,4 @@ cloudfront_cache_policy: name: "{{ resource_prefix }}-my-cache-policy" state: absent - ignore_errors: true \ No newline at end of file + ignore_errors: true \ No newline at end of file From 5f1901d6ab0a1cad01f690c8c28fe8979b753fcf Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Wed, 17 Jan 2024 10:10:41 -0800 Subject: [PATCH 35/70] cloudfront_origin_request_policy: Fixed spacing on integration test --- .../targets/cloudfront_origin_request_policy/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml b/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml index 05a58c2a062..a1ef4104dd3 100644 --- a/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml @@ -100,4 +100,4 @@ cloudfront_origin_request_policy: name: "{{ resource_prefix }}-my-origin-request-policy" state: absent - ignore_errors: true \ No newline at end of file + ignore_errors: true \ No newline at end of file From 844b5e1b2a49a0dd47dacc62f590afe3d2b0af9f Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Wed, 17 Jan 2024 10:46:57 -0800 Subject: [PATCH 36/70] cloudfront_cache_policy: Fixed null list error --- plugins/modules/cloudfront_cache_policy.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 0c8a3a7a7cd..970524e548c 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -365,8 +365,7 @@ def __init__(self, module): def find_cache_policy(self, name): try: - # We only get the custom policies to make the query more efficient - policies = self.client.list_cache_policies(Type="custom")["CachePolicyList"]["Items"] + policies = self.client.list_cache_policies()["CachePolicyList"]["Items"] for policy in policies: if policy["CachePolicy"]["CachePolicyConfig"]["Name"] == name: From 85bfd8f05bac10e46760fe1aa5e2e35d8b899fbc Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Wed, 17 Jan 2024 10:47:10 -0800 Subject: [PATCH 37/70] cloudfront_origin_request_policy: Fixed null list error --- plugins/modules/cloudfront_origin_request_policy.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 8e86a11e170..2045795e671 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -248,8 +248,7 @@ def __init__(self, module): def find_origin_request_policy(self, name): try: - # We only get the custom policies to make the query more efficient - policies = self.client.list_origin_request_policies(Type="custom")["OriginRequestPolicyList"]["Items"] + policies = self.client.list_origin_request_policies()["OriginRequestPolicyList"]["Items"] for policy in policies: if policy["OriginRequestPolicy"]["OriginRequestPolicyConfig"]["Name"] == name: From 6cace09f4be7eab962a1564775f86c2db80e9f3f Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Thu, 18 Jan 2024 10:11:04 -0800 Subject: [PATCH 38/70] cloudfront_cache_policy: Added filter to list function to make it more efficient --- plugins/modules/cloudfront_cache_policy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 970524e548c..74f0fdf0bb0 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -365,7 +365,8 @@ def __init__(self, module): def find_cache_policy(self, name): try: - policies = self.client.list_cache_policies()["CachePolicyList"]["Items"] + # Only list the custom policies as those are the only ones we can change + policies = self.client.list_cache_policies(Type="custom").get('CachePolicyList', {}).get('Items', []): for policy in policies: if policy["CachePolicy"]["CachePolicyConfig"]["Name"] == name: From cd9ab592a684cd36cc30b6da270c4abf1232f31b Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Thu, 18 Jan 2024 10:11:16 -0800 Subject: [PATCH 39/70] cloudfront_origin_request_policy: Added filter to list function to make it more efficient --- plugins/modules/cloudfront_origin_request_policy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 2045795e671..0b748252ea4 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -248,7 +248,8 @@ def __init__(self, module): def find_origin_request_policy(self, name): try: - policies = self.client.list_origin_request_policies()["OriginRequestPolicyList"]["Items"] + # Only list the custom policies as those are the only ones we can change + policies = self.client.list_origin_request_policies(Type="custom").get('OriginRequestPolicyList', {}).get('Items', []) for policy in policies: if policy["OriginRequestPolicy"]["OriginRequestPolicyConfig"]["Name"] == name: From e2175a0e442bcd5e34a4fcdca04453bdc0ba3293 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Thu, 18 Jan 2024 10:13:21 -0800 Subject: [PATCH 40/70] cloudfront_cache_policy: Added filter to list function to make it more efficient --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 74f0fdf0bb0..7167515d751 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -366,7 +366,7 @@ def __init__(self, module): def find_cache_policy(self, name): try: # Only list the custom policies as those are the only ones we can change - policies = self.client.list_cache_policies(Type="custom").get('CachePolicyList', {}).get('Items', []): + policies = self.client.list_cache_policies(Type="custom").get('CachePolicyList', {}).get('Items', []) for policy in policies: if policy["CachePolicy"]["CachePolicyConfig"]["Name"] == name: From a0c8fb474c6efe3d45e46fbe49c5bcbbaa2ce223 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Thu, 18 Jan 2024 10:16:15 -0800 Subject: [PATCH 41/70] cloudfront_cache_policy: Fixed linter issues --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 7167515d751..13f091ed885 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -366,7 +366,7 @@ def __init__(self, module): def find_cache_policy(self, name): try: # Only list the custom policies as those are the only ones we can change - policies = self.client.list_cache_policies(Type="custom").get('CachePolicyList', {}).get('Items', []) + policies = self.client.list_cache_policies(Type="custom").get("CachePolicyList", {}).get("Items", []) for policy in policies: if policy["CachePolicy"]["CachePolicyConfig"]["Name"] == name: From 05e2bcf6120fb2eb76c87f5710236bd44fa67e13 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Thu, 18 Jan 2024 10:16:42 -0800 Subject: [PATCH 42/70] cloudfront_origin_request_policy: Fixed linter issues --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 0b748252ea4..aee1fa3e5b7 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -249,7 +249,7 @@ def __init__(self, module): def find_origin_request_policy(self, name): try: # Only list the custom policies as those are the only ones we can change - policies = self.client.list_origin_request_policies(Type="custom").get('OriginRequestPolicyList', {}).get('Items', []) + policies = self.client.list_origin_request_policies(Type="custom").get("OriginRequestPolicyList", {}).get("Items", []) for policy in policies: if policy["OriginRequestPolicy"]["OriginRequestPolicyConfig"]["Name"] == name: From c55a12b50271177ca5845c888e24c2961795d0c8 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Thu, 18 Jan 2024 10:22:02 -0800 Subject: [PATCH 43/70] cloudfront_origin_request_policy: Fixed linter issues --- plugins/modules/cloudfront_origin_request_policy.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index aee1fa3e5b7..772ca076a73 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -248,8 +248,12 @@ def __init__(self, module): def find_origin_request_policy(self, name): try: - # Only list the custom policies as those are the only ones we can change - policies = self.client.list_origin_request_policies(Type="custom").get("OriginRequestPolicyList", {}).get("Items", []) + policies = ( + # Only list the custom policies as those are the only ones we can change + self.client.list_origin_request_policies(Type="custom") + .get("OriginRequestPolicyList", {}) + .get("Items", []) + ) for policy in policies: if policy["OriginRequestPolicy"]["OriginRequestPolicyConfig"]["Name"] == name: From 6842f4357c5506b24a13b4279e37bbadb31f0fad Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Thu, 18 Jan 2024 11:13:02 -0800 Subject: [PATCH 44/70] cloudfront_origin_request_policy: Fixed linter issues --- plugins/modules/cloudfront_origin_request_policy.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 772ca076a73..2045795e671 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -248,12 +248,7 @@ def __init__(self, module): def find_origin_request_policy(self, name): try: - policies = ( - # Only list the custom policies as those are the only ones we can change - self.client.list_origin_request_policies(Type="custom") - .get("OriginRequestPolicyList", {}) - .get("Items", []) - ) + policies = self.client.list_origin_request_policies()["OriginRequestPolicyList"]["Items"] for policy in policies: if policy["OriginRequestPolicy"]["OriginRequestPolicyConfig"]["Name"] == name: From 3bc00bcbab3374234b8a9b832cfdeba101e4af9b Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Thu, 18 Jan 2024 11:13:44 -0800 Subject: [PATCH 45/70] cloudfront_cache_policy: Fixed linter issues --- plugins/modules/cloudfront_cache_policy.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 13f091ed885..970524e548c 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -365,8 +365,7 @@ def __init__(self, module): def find_cache_policy(self, name): try: - # Only list the custom policies as those are the only ones we can change - policies = self.client.list_cache_policies(Type="custom").get("CachePolicyList", {}).get("Items", []) + policies = self.client.list_cache_policies()["CachePolicyList"]["Items"] for policy in policies: if policy["CachePolicy"]["CachePolicyConfig"]["Name"] == name: From 7d7148f7f641e1eedd1cda8a642ebce7b6b53590 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Fri, 16 Feb 2024 19:55:41 -0800 Subject: [PATCH 46/70] cloudfront_cache_policy: Check default_ttl --- .../integration/targets/cloudfront_cache_policy/tasks/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml index 96ce180bca8..e57c4f7cc20 100644 --- a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml @@ -13,6 +13,7 @@ cloudfront_cache_policy: name: "{{ resource_prefix }}-my-cache-policy" comment: Created by Ansible test + default_ttl: 86400 min_ttl: 1 max_ttl: 31536000 parameters_in_cache_key_and_forwarded_to_origin: @@ -38,6 +39,7 @@ cloudfront_cache_policy: name: "{{ resource_prefix }}-my-cache-policy" comment: Created by Ansible test + default_ttl: 86400 min_ttl: 1 max_ttl: 31536000 parameters_in_cache_key_and_forwarded_to_origin: From eb65d0bcc344cb8223dd6fb36e0a2d906ca60b81 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Fri, 16 Feb 2024 20:50:53 -0800 Subject: [PATCH 47/70] cloudfront_cache_policy: Adjust test cases --- .../cloudfront_cache_policy/tasks/main.yml | 25 ------------------- .../tasks/main.yml | 19 -------------- 2 files changed, 44 deletions(-) diff --git a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml index e57c4f7cc20..b17d472b015 100644 --- a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml @@ -35,31 +35,6 @@ - create_result is not failed - create_result.cache_policy.cache_policy_config.name == "{{ resource_prefix }}-my-cache-policy" - - name: Rerun same task to ensure idempotence - cloudfront_cache_policy: - name: "{{ resource_prefix }}-my-cache-policy" - comment: Created by Ansible test - default_ttl: 86400 - min_ttl: 1 - max_ttl: 31536000 - parameters_in_cache_key_and_forwarded_to_origin: - enable_accept_encoding_gzip: false - enable_accept_encoding_brotli: false - headers_config: - header_behavior: none - cookies_config: - cookie_behavior: none - query_strings_config: - query_string_behavior: none - state: present - register: rerun_result - - - name: Assert no change and no errors - assert: - that: - - rerun_result is not changed - - rerun_result is not failed - - name: Update existing policy with more complicated configuration cloudfront_cache_policy: name: "{{ resource_prefix }}-my-cache-policy" diff --git a/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml b/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml index a1ef4104dd3..87da6ec2486 100644 --- a/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml @@ -29,25 +29,6 @@ - create_result is not failed - create_result.origin_request_policy.origin_request_policy_config.name == "{{ resource_prefix }}-my-origin-request-policy" - - name: Rerun same task to ensure idempotence - cloudfront_origin_request_policy: - name: "{{ resource_prefix }}-my-origin-request-policy" - comment: Created by Ansible test - headers_config: - header_behavior: none - cookies_config: - cookie_behavior: none - query_strings_config: - query_string_behavior: none - state: present - register: rerun_result - - - name: Assert no change and no errors - assert: - that: - - rerun_result is not changed - - rerun_result is not failed - - name: Update existing policy with more complicated configuration cloudfront_origin_request_policy: name: "{{ resource_prefix }}-my-origin-request-policy" From 15ee63d3fdfc740f70a98f6eed51311e74fbd6f6 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Fri, 16 Feb 2024 21:47:58 -0800 Subject: [PATCH 48/70] cloudfront_cache_policy: Fix recursive insertion of items quantity --- plugins/modules/cloudfront_cache_policy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 970524e548c..90550d87dc0 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -457,10 +457,10 @@ def insert_quantities(dict_with_items): if "Items" in dict_with_items and isinstance(dict_with_items["Items"], list): dict_with_items["Quantity"] = len(dict_with_items["Items"]) - # Items on second level case + # Recursively check sub-dict for k, v in dict_with_items.items(): - if isinstance(v, dict) and "Items" in v: - v["Quantity"] = len(v["Items"]) + if isinstance(v, dict): + v = self.insert_quantities(v) return dict_with_items From 15b26174d686f48ff5a748bb5ac545e1254a4fba Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Fri, 16 Feb 2024 21:51:07 -0800 Subject: [PATCH 49/70] cloudfront_cache_policy: Fix recursive insertion of items quantity --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 90550d87dc0..71cfc3ca968 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -460,7 +460,7 @@ def insert_quantities(dict_with_items): # Recursively check sub-dict for k, v in dict_with_items.items(): if isinstance(v, dict): - v = self.insert_quantities(v) + v = CloudfrontCachePolicyService.insert_quantities(v) return dict_with_items From 676ef8464bbfd1212a1acd838f9356d808e6e722 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Sat, 17 Feb 2024 00:19:58 -0800 Subject: [PATCH 50/70] cloudfront_cache_policy: Fixed deletion test case --- plugins/modules/cloudfront_origin_request_policy.py | 6 +++--- .../targets/cloudfront_cache_policy/tasks/main.yml | 2 +- .../targets/cloudfront_origin_request_policy/tasks/main.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 2045795e671..3c359e6ab97 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -337,10 +337,10 @@ def insert_quantities(dict_with_items): if "Items" in dict_with_items and isinstance(dict_with_items["Items"], list): dict_with_items["Quantity"] = len(dict_with_items["Items"]) - # Items on second level case + # Recursively check sub-dict for k, v in dict_with_items.items(): - if isinstance(v, dict) and "Items" in v: - v["Quantity"] = len(v["Items"]) + if isinstance(v, dict): + v = CloudfrontOriginRequestPolicyService.insert_quantities(v) return dict_with_items diff --git a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml index b17d472b015..dcc23f2b2f6 100644 --- a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml @@ -85,7 +85,7 @@ that: - delete_result is changed - delete_result is not failed - - update_result.cache_policy is undefined + - delete_result.cache_policy is undefined always: diff --git a/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml b/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml index 87da6ec2486..e2757fdaec3 100644 --- a/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml @@ -73,7 +73,7 @@ that: - delete_result is changed - delete_result is not failed - - update_result.origin_request_policy is undefined + - delete_result.origin_request_policy is undefined always: From e363d852a20830ceadc6a40b5e5d96e3b1dd426e Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:25:59 -0700 Subject: [PATCH 51/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 3c359e6ab97..46ce13ee260 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -221,7 +221,7 @@ description: - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html). type: list elements: str """ From 71a05f8fcc788d5ae0dc6060420d738dd338d7fd Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:26:08 -0700 Subject: [PATCH 52/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 46ce13ee260..a75ccdcf14e 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -210,7 +210,7 @@ description: - The URL query strings from viewer requests to include in origin requests. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html). type: dict contains: query_string_behavior: From b232ee76fc9610604722742cd956d4b6cbfe815b Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:26:16 -0700 Subject: [PATCH 53/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index a75ccdcf14e..d7e803616f1 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -193,7 +193,7 @@ description: - The cookies from viewer requests to include in origin requests. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html). type: dict contains: cookie_behavior: From f7f9591ea27269ea12dc99f6740dea1b96854bb3 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:26:23 -0700 Subject: [PATCH 54/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index d7e803616f1..b1ec1a8e87c 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -176,7 +176,7 @@ description: - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html). type: dict contains: header_behavior: From 069859770b76091aa8e3e24e39c8fee583ff937a Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:26:33 -0700 Subject: [PATCH 55/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index b1ec1a8e87c..5a201d7a669 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -79,7 +79,7 @@ description: - The URL query strings from viewer requests to include in origin requests. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyQueryStringsConfig.html). required: false type: dict suboptions: From 9a40501cd688a2499f1cecbaf352fca2da6f2c24 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:26:38 -0700 Subject: [PATCH 56/70] Update plugins/modules/cloudfront_cache_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 71cfc3ca968..256a4b56868 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -14,7 +14,7 @@ description: - Create, update and delete cache policies to be used in a Cloudfront distribution's cache behavior for configurating the cache key as well as the default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache. - - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_cache_policy.html) + - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_cache_policy.html). author: - Zac Lovoy (@zwlovoy) From a5288a83343586ef17776756944bc4360758eb31 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:26:44 -0700 Subject: [PATCH 57/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 5a201d7a669..3de2a6da0fc 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -14,7 +14,7 @@ description: - Create, update and delete origin request policies to be used in a Cloudfront distribution's cache behavior for determining the values that CloudFront includes in requests that it sends to the origin. - - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_origin_request_policy.html) + - See docs at U(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront/client/create_origin_request_policy.html). author: - Zac Lovoy (@zwlovoy) From ea94556a83102423f822f5eeb0c338ccf81bdc1e Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:28:45 -0700 Subject: [PATCH 58/70] Update plugins/modules/cloudfront_cache_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 256a4b56868..37231148658 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -209,7 +209,7 @@ RETURN = r""" cache_policy: - description: The policy's information + description: The policy's information. returned: success type: complex contains: From a9db265f7c9477c244f852beac3aba889e512579 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:28:54 -0700 Subject: [PATCH 59/70] Update plugins/modules/cloudfront_cache_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 37231148658..8bd9422f1e3 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -6,7 +6,7 @@ DOCUMENTATION = r""" --- -version_added: 7.2.0 +version_added: 9.0.0 module: cloudfront_cache_policy short_description: Create, update and delete cache policies to be used in a Cloudfront distribution's cache behavior From 969ca95a95f0b51a2b1c1bdd259338d192aa27a3 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:29:04 -0700 Subject: [PATCH 60/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 3de2a6da0fc..899c7c66aaf 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -71,7 +71,7 @@ cookies: description: - Contains a list of cookie names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html). type: list elements: str required: false From 367284cc2379add7345927d3b7675bf3e0933ae6 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:29:15 -0700 Subject: [PATCH 61/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 899c7c66aaf..5e16bb5d73d 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -59,7 +59,7 @@ description: - The cookies from viewer requests to include in origin requests. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyCookiesConfig.html). type: dict required: false suboptions: From 1000228c10c801f02d89fe1f5e1c7196e88f188c Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:29:25 -0700 Subject: [PATCH 62/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 5e16bb5d73d..e694758bb13 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -147,7 +147,7 @@ RETURN = r""" origin_request_policy: - description: The policy's information + description: The policy's information. returned: success type: complex contains: From 95a42910b5940b1489c24d43c59f725a60e43957 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:29:38 -0700 Subject: [PATCH 63/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index e694758bb13..06a5e366c56 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -91,7 +91,7 @@ query_strings: description: - Contains the specific query strings in viewer requests that either are or are not included in requests that CloudFront sends to the origin. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html) + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_QueryStringNames.html). type: list elements: str required: false From 85eb2c21ccdb56815b538f2fbbc01efaebf2541a Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:29:47 -0700 Subject: [PATCH 64/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 06a5e366c56..2542456ef8e 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -39,7 +39,7 @@ description: - The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_OriginRequestPolicyHeadersConfig.html). type: dict required: false suboptions: From a11945698095c8226fd2a869736da00514d7c0f8 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:29:56 -0700 Subject: [PATCH 65/70] Update plugins/modules/cloudfront_cache_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 8bd9422f1e3..0a6178896f5 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -324,7 +324,7 @@ - An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyQueryStringsConfig.html). type: dict contains: query_string_behavior: From ee8223c85300917ab4103bafcde2442bb3b83c50 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:30:08 -0700 Subject: [PATCH 66/70] Update plugins/modules/cloudfront_cache_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 0a6178896f5..cdf3ed3ac9f 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -316,7 +316,7 @@ description: - Contains a list of cookie names. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CookieNames.html). type: list elements: str query_strings_config: From f198cbe3dc24fb7469d32acd679c7c2808477611 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:30:17 -0700 Subject: [PATCH 67/70] Update plugins/modules/cloudfront_cache_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index cdf3ed3ac9f..1d0f6a2c0d8 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -303,7 +303,7 @@ - An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyCookiesConfig.html). type: dict contains: cookie_behavior: From 53bbb461356cc52875b3197e520b9c58d1486511 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:30:24 -0700 Subject: [PATCH 68/70] Update plugins/modules/cloudfront_cache_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 1d0f6a2c0d8..3ad0178dcb8 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -282,7 +282,7 @@ - An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CachePolicyHeadersConfig.html). type: dict contains: header_behavior: From 6a49a10498a0423ef760030451c98105ce03ade5 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:30:36 -0700 Subject: [PATCH 69/70] Update plugins/modules/cloudfront_cache_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_cache_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_cache_policy.py b/plugins/modules/cloudfront_cache_policy.py index 3ad0178dcb8..ac45f108615 100644 --- a/plugins/modules/cloudfront_cache_policy.py +++ b/plugins/modules/cloudfront_cache_policy.py @@ -264,7 +264,7 @@ - The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin. - For more information see the CloudFront documentation at - U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html) + U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ParametersInCacheKeyAndForwardedToOrigin.html). type: dict contains: enable_accept_encoding_gzip: From 9d49a0ddead852ae62bf61f643a0cd2cf6d18efa Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:30:45 -0700 Subject: [PATCH 70/70] Update plugins/modules/cloudfront_origin_request_policy.py Co-authored-by: Alina Buzachis --- plugins/modules/cloudfront_origin_request_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudfront_origin_request_policy.py b/plugins/modules/cloudfront_origin_request_policy.py index 2542456ef8e..e6a5c886092 100644 --- a/plugins/modules/cloudfront_origin_request_policy.py +++ b/plugins/modules/cloudfront_origin_request_policy.py @@ -51,7 +51,7 @@ headers: description: - Contains a list of HTTP header names. - - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html) + - For more information see the CloudFront documentation at U(https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Headers.html). type: list elements: str required: false