Skip to content

Commit

Permalink
update integration tests to delete cloudfront distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
abikouo committed Nov 22, 2022
1 parent 1b281de commit 839036b
Showing 1 changed file with 37 additions and 21 deletions.
58 changes: 37 additions & 21 deletions tests/integration/targets/cloudfront_distribution/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
default_cache_behavior:
target_origin_id: "{{ cloudfront_hostname }}-origin.example.com"
state: present
purge_origins: yes
purge_origins: true
register: cf_distribution

- set_fact:
Expand Down Expand Up @@ -49,7 +49,7 @@
cloudfront_distribution:
state: present
distribution_id: "{{ distribution_id }}"
ipv6_enabled: True
ipv6_enabled: true
register: cf_update_ipv6

- name: ensure the 'ipv6_enabled' value has changed (new value is true)
Expand All @@ -76,7 +76,7 @@
cloudfront_distribution:
state: present
distribution_id: "{{ distribution_id }}"
ipv6_enabled: True
ipv6_enabled: true
register: cf_update_ipv6

- name: ensure the 'ipv6_enabled' value has changed (new value is true)
Expand Down Expand Up @@ -167,7 +167,7 @@
id: "{{ resource_prefix }}2.example.com"
default_root_object: index.html
state: present
wait: yes
wait: true
register: cf_add_origin

- name: ensure origin was added
Expand All @@ -186,7 +186,7 @@
http_port: 8080
- domain_name: "{{ resource_prefix }}2.example.com"
default_root_object: index.html
wait: yes
wait: true
state: present
register: cf_rerun_second_origin

Expand Down Expand Up @@ -221,7 +221,7 @@
- domain_name: "{{ resource_prefix }}2.example.com"
default_cache_behavior:
target_origin_id: "{{ resource_prefix }}2.example.com"
purge_origins: yes
purge_origins: true
state: present
register: cf_purge_origin

Expand Down Expand Up @@ -278,11 +278,11 @@
- name: delete distribution
cloudfront_distribution:
distribution_id: "{{ distribution_id }}"
enabled: no
wait: yes
enabled: false
wait: true
state: absent

- name: create distribution with tags
- name: create cloudfront distribution with tags
cloudfront_distribution:
origins:
- domain_name: "{{ resource_prefix }}2.example.com"
Expand Down Expand Up @@ -313,7 +313,7 @@
tags:
ATag: tag1
Another: tag
purge_tags: yes
purge_tags: true
state: present
register: rerun_with_purge_tags

Expand All @@ -330,7 +330,7 @@
- domain_name: "{{ resource_prefix }}2.example.com"
tags:
Third: thing
purge_tags: no
purge_tags: false
state: present
register: update_with_new_tag

Expand Down Expand Up @@ -373,7 +373,7 @@
origins:
- domain_name: "{{ resource_prefix }}2.example.com"
cache_behaviors: "{{ cloudfront_test_cache_behaviors|reverse|list }}"
purge_cache_behaviors: yes
purge_cache_behaviors: true
state: present
register: reverse_cache_behaviors_with_purge

Expand All @@ -389,10 +389,10 @@
origins:
- domain_name: "{{ resource_prefix }}3.example.com"
id: "{{ resource_prefix }}3.example.com"
purge_origins: yes
purge_origins: true
state: present
register: remove_origin_in_use
ignore_errors: yes
ignore_errors: true

- name: check that removing in use origin fails
assert:
Expand Down Expand Up @@ -431,7 +431,7 @@
origins:
- domain_name: "{{ resource_prefix }}-bucket.s3.amazonaws.com"
id: "{{ resource_prefix }}3.example.com"
s3_origin_access_identity_enabled: yes
s3_origin_access_identity_enabled: true
state: present
register: update_origin_to_s3

Expand All @@ -448,7 +448,7 @@
origins:
- domain_name: "{{ resource_prefix }}-bucket.s3.amazonaws.com"
id: "{{ resource_prefix }}3.example.com"
s3_origin_access_identity_enabled: no
s3_origin_access_identity_enabled: false
state: present
register: update_origin_to_s3_without_origin_access

Expand All @@ -470,12 +470,12 @@
origins:
- domain_name: "{{ resource_prefix }}-bucket.s3.amazonaws.com"
id: "{{ resource_prefix }}3.example.com"
s3_origin_access_identity_enabled: yes
s3_origin_access_identity_enabled: true
custom_origin_config:
origin_protocol_policy: 'http-only'
state: present
register: update_origin_to_s3_with_origin_access_and_with_custom_origin_config
ignore_errors: True
ignore_errors: true

- name: check that custom origin with origin access identity fails
assert:
Expand Down Expand Up @@ -519,8 +519,24 @@

- name: clean up cloudfront distribution
cloudfront_distribution:
distribution_id: "{{ distribution_id }}"
enabled: no
wait: yes
distribution_id: "{{ item }}"
enabled: false
wait: true
state: absent
register: delete_distribution
ignore_errors: true
async: 1000
poll: 0
with_items:
- '{{ cf_second_distribution.id }}'
- '{{ cf_distribution.id }}'

- name: Wait for cloudfront to be deleted
async_status:
jid: "{{ item.ansible_job_id }}"
register: _delete
until: _delete.finished
retries: 100
delay: 5
loop: "{{ delete_distribution.results }}"
ignore_errors: true

0 comments on commit 839036b

Please sign in to comment.