-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdestroy.yml
35 lines (33 loc) · 1.11 KB
/
destroy.yml
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
35
---
- hosts: 127.0.0.1
environment:
AWS_SECURITY_TOKEN: "{{ (ansible_env|default({})).AWS_SESSION_TOKEN|default('') }}"
connection: local
# Check for prerequisites
tasks:
- name: make sure we have java 1.8 installed.
shell: "java -version 2>&1 |grep 1.8"
register: javatest_result
failed_when: "javatest_result.rc != 0"
- name: make sure jq is installed
shell: "which jq"
register: jq_result
failed_when: "jq_result.rc != 0"
- name: make sure we have connection to AWS.
shell: "aws s3 ls"
register: aws_result
failed_when: "aws_result.rc != 0"
# Delete Resources
- name: Delete S3 Bucket
s3: bucket={{lambda_s3_bucket}} mode=delete
- name: Delete CloudFormation Stack
cloudformation:
stack_name: "{{ stack_name }}"
state: "absent"
region: "{{ region }}"
disable_rollback: true
- name: Get API Gateway ID
shell: aws apigateway get-rest-apis |jq -r '.items[] | select(.name | contains("{{ title }}")) | .id'
register: apigwid
- name: Delete API Gateway
shell: aws apigateway delete-rest-api --rest-api-id "{{ apigwid.stdout }}"