Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Modules: cloudfront_cache_policy and cloudfront_origin_request_policy #2046

Open
wants to merge 80 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
fe55eec
New Module: cloudfront_cache_policy
Zozman Jan 9, 2024
2eb76d0
New Module: cloudfront_cache_policy
Zozman Jan 9, 2024
0e849cb
Merge branch 'cloudfrontCreateCacheAndOriginPolicy' of github.com:Zoz…
Zozman Jan 9, 2024
3e5e53c
New Module: cloudfront_cache_policy
Zozman Jan 10, 2024
6239cf7
New Module: cloudfront_cache_policy
Zozman Jan 10, 2024
79a883f
New Module: cloudfront_cache_policy
Zozman Jan 10, 2024
07d8d8c
New Module: cloudfront_cache_policy
Zozman Jan 10, 2024
8e0dbfc
New Module: cloudfront_origin_request_policy
Zozman Jan 10, 2024
4800216
Merge branch 'ansible-collections:main' into cloudfrontCreateCacheAnd…
Zozman Jan 12, 2024
2135acf
cloudfront_origin_request_policy: Fixed documentation spacing
Zozman Jan 16, 2024
a48828f
Merge branch 'cloudfrontCreateCacheAndOriginPolicy' of github.com:Zoz…
Zozman Jan 16, 2024
1410d22
cloudfront_cache_policy: Fixed documentation spacing
Zozman Jan 16, 2024
98c6aa5
cloudfront_cache_policy: Fixed documentation spacing
Zozman Jan 16, 2024
96b6462
cloudfront_origin_request_policy: Fixed documentation spacing
Zozman Jan 16, 2024
8da255e
cloudfront_cache_policy: Fixed code spacing
Zozman Jan 16, 2024
ac52b55
cloudfront_origin_request_policy: Fixed code spacing
Zozman Jan 16, 2024
f14cdcb
cloudfront_cache_policy: Fixed formatting
Zozman Jan 16, 2024
ceee2da
cloudfront_origin_request_policy: Fixed formatting
Zozman Jan 16, 2024
7f57478
cloudfront_cache_policy: Fixed documentation
Zozman Jan 16, 2024
d12ac4a
cloudfront_origin_request_policy: Fixed examples
Zozman Jan 16, 2024
424d4b3
cloudfront_cache_policy: Fixed return values
Zozman Jan 16, 2024
53f8927
cloudfront_origin_request_policy: Fixed return values
Zozman Jan 16, 2024
7019f41
cloudfront_origin_request_policy: Fixed spacing
Zozman Jan 16, 2024
9667bfe
cloudfront_cache_policy: Fixed spacing
Zozman Jan 16, 2024
6ab8821
cloudfront_origin_request_policy: Fixed line lengths
Zozman Jan 16, 2024
4af9a90
cloudfront_cache_policy: Fixed line lengths
Zozman Jan 16, 2024
37416cc
cloudfront_cache_policy: Fixed line lengths
Zozman Jan 16, 2024
f7e651f
cloudfront_cache_policy + cloudfront_origin_request_policy: Added cha…
Zozman Jan 17, 2024
faf6841
cloudfront_cache_policy: Updated spacing
Zozman Jan 17, 2024
e5fea92
cloudfront_origin_request_policy: Updated spacing
Zozman Jan 17, 2024
76414d3
cloudfront_origin_request_policy: Updated spacing
Zozman Jan 17, 2024
bab83ba
cloudfront_cache_policy: Updated spacing
Zozman Jan 17, 2024
e343e46
cloudfront_cache_policy: Fixed property permissions to support deleti…
Zozman Jan 17, 2024
e32092d
cloudfront_origin_request_policy: Fixed property permissions to suppo…
Zozman Jan 17, 2024
50a9021
cloudfront_cache_policy: Added filter to list function to make it mor…
Zozman Jan 17, 2024
56da3d0
cloudfront_origin_request_policy: Added filter to list function to ma…
Zozman Jan 17, 2024
8b6d180
cloudfront_cache_policy: Fixed spacing on integration test
Zozman Jan 17, 2024
5f1901d
cloudfront_origin_request_policy: Fixed spacing on integration test
Zozman Jan 17, 2024
844b5e1
cloudfront_cache_policy: Fixed null list error
Zozman Jan 17, 2024
85bfd8f
cloudfront_origin_request_policy: Fixed null list error
Zozman Jan 17, 2024
6cace09
cloudfront_cache_policy: Added filter to list function to make it mor…
Zozman Jan 18, 2024
cd9ab59
cloudfront_origin_request_policy: Added filter to list function to ma…
Zozman Jan 18, 2024
e2175a0
cloudfront_cache_policy: Added filter to list function to make it mor…
Zozman Jan 18, 2024
a0c8fb4
cloudfront_cache_policy: Fixed linter issues
Zozman Jan 18, 2024
05e2bcf
cloudfront_origin_request_policy: Fixed linter issues
Zozman Jan 18, 2024
c55a12b
cloudfront_origin_request_policy: Fixed linter issues
Zozman Jan 18, 2024
6842f43
cloudfront_origin_request_policy: Fixed linter issues
Zozman Jan 18, 2024
3bc00bc
cloudfront_cache_policy: Fixed linter issues
Zozman Jan 18, 2024
7d7148f
cloudfront_cache_policy: Check default_ttl
Zozman Feb 17, 2024
eb65d0b
cloudfront_cache_policy: Adjust test cases
Zozman Feb 17, 2024
15ee63d
cloudfront_cache_policy: Fix recursive insertion of items quantity
Zozman Feb 17, 2024
15b2617
cloudfront_cache_policy: Fix recursive insertion of items quantity
Zozman Feb 17, 2024
676ef84
cloudfront_cache_policy: Fixed deletion test case
Zozman Feb 17, 2024
ffab414
Merge branch 'ansible-collections:main' into cloudfrontCreateCacheAnd…
Zozman Jul 17, 2024
64a3ee0
Merge branch 'ansible-collections:main' into cloudfrontCreateCacheAnd…
Zozman Jul 24, 2024
071e727
Merge branch 'ansible-collections:main' into cloudfrontCreateCacheAnd…
Zozman Aug 11, 2024
15fffa9
Merge branch 'ansible-collections:main' into cloudfrontCreateCacheAnd…
Zozman Aug 23, 2024
a17f219
Merge branch 'ansible-collections:main' into cloudfrontCreateCacheAnd…
Zozman Sep 6, 2024
9f115ba
Merge branch 'ansible-collections:main' into cloudfrontCreateCacheAnd…
Zozman Sep 26, 2024
77724ed
Merge branch 'ansible-collections:main' into cloudfrontCreateCacheAnd…
Zozman Oct 21, 2024
e363d85
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
71a05f8
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
b232ee7
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
f7f9591
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
0698597
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
9a40501
Update plugins/modules/cloudfront_cache_policy.py
Zozman Oct 22, 2024
a5288a8
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
ea94556
Update plugins/modules/cloudfront_cache_policy.py
Zozman Oct 22, 2024
a9db265
Update plugins/modules/cloudfront_cache_policy.py
Zozman Oct 22, 2024
969ca95
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
367284c
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
1000228
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
95a4291
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
85eb2c2
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
a119456
Update plugins/modules/cloudfront_cache_policy.py
Zozman Oct 22, 2024
ee8223c
Update plugins/modules/cloudfront_cache_policy.py
Zozman Oct 22, 2024
f198cbe
Update plugins/modules/cloudfront_cache_policy.py
Zozman Oct 22, 2024
53bbb46
Update plugins/modules/cloudfront_cache_policy.py
Zozman Oct 22, 2024
6a49a10
Update plugins/modules/cloudfront_cache_policy.py
Zozman Oct 22, 2024
9d49a0d
Update plugins/modules/cloudfront_origin_request_policy.py
Zozman Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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)."
2 changes: 2 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ action_groups:
- batch_job_queue
- cloudformation_exports_info
- cloudformation_stack_set
- cloudfront_cache_policy
- cloudfront_distribution
- cloudfront_distribution_info
- cloudfront_info
- cloudfront_invalidation
- cloudfront_origin_access_identity
- cloudfront_origin_request_policy
- cloudfront_response_headers_policy
- codebuild_project
- codecommit_repository
Expand Down
502 changes: 502 additions & 0 deletions plugins/modules/cloudfront_cache_policy.py

Large diffs are not rendered by default.

376 changes: 376 additions & 0 deletions plugins/modules/cloudfront_origin_request_policy.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/integration/targets/cloudfront_cache_policy/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cloud/aws
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dependencies: []
96 changes: 96 additions & 0 deletions tests/integration/targets/cloudfront_cache_policy/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---

- 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also please add some tests for check_mode and idempotency?

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: 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-cache-policy"

- name: Update existing policy with more complicated configuration
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: 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.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:
name: "{{ resource_prefix }}-my-cache-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
- delete_result.cache_policy is undefined

always:

- name: Ensure policy is deleted
cloudfront_cache_policy:
name: "{{ resource_prefix }}-my-cache-policy"
state: absent
ignore_errors: true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cloud/aws
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dependencies: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---

- 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: 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
- delete_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
Loading