From 839036baeb9ed842705ec20a85ba0de5fd7af0e2 Mon Sep 17 00:00:00 2001 From: abikouo Date: Tue, 22 Nov 2022 12:33:40 +0100 Subject: [PATCH] update integration tests to delete cloudfront distribution --- .../cloudfront_distribution/tasks/main.yml | 58 ++++++++++++------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/tests/integration/targets/cloudfront_distribution/tasks/main.yml b/tests/integration/targets/cloudfront_distribution/tasks/main.yml index f80797ebbef..6f4fa37edcb 100644 --- a/tests/integration/targets/cloudfront_distribution/tasks/main.yml +++ b/tests/integration/targets/cloudfront_distribution/tasks/main.yml @@ -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: @@ -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) @@ -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) @@ -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 @@ -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 @@ -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 @@ -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" @@ -313,7 +313,7 @@ tags: ATag: tag1 Another: tag - purge_tags: yes + purge_tags: true state: present register: rerun_with_purge_tags @@ -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 @@ -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 @@ -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: @@ -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 @@ -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 @@ -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: @@ -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