Guillaume Coré
2020-03-11 1d970fbaa4bd88c9d094d9587db59fdf9cd0239a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
- import_tasks: ec2_detect_region_tasks.yml
 
- name: Destroy cloudformation template
  cloudformation:
    aws_access_key: "{{ aws_access_key_id }}"
    aws_secret_key: "{{ aws_secret_access_key }}"
    stack_name: "{{project_tag}}"
    state: "absent"
    region: "{{aws_region_final|d(aws_region)}}"
    disable_rollback: false
    tags:
      Stack: "project {{env_type}}-{{ guid }}"
  tags:
    - destroying
    - destroy_cf_deployment
    - destroy_cloud_deployment
  register: cloudformation_result
  until: cloudformation_result is succeeded
  retries: "{{ cloudformation_retries | d(3) }}"
  delay: "{{ cloudformation_retry_delay | d(60) }}"
  ignore_errors: yes
  when: cloud_provider == 'ec2'
 
- name: report Cloudformation error
  fail:
    msg: "FAIL {{ project_tag }} Destroy Cloudformation"
  when:
    - not cloudformation_result is succeeded
    - cloud_provider == 'ec2'
  tags:
    - destroying
    - destroy_cf_deployment
    - destroy_cloud_deployment