-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcloudformation_example.yml
More file actions
64 lines (57 loc) · 1.55 KB
/
cloudformation_example.yml
File metadata and controls
64 lines (57 loc) · 1.55 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
# Example Ansible playbook for AWS CloudFormation
# Note: This playbook requires valid AWS credentials to run
- name: AWS CloudFormation Example
hosts: localhost
connection: local
gather_facts: false
vars:
aws_region: us-west-2
stack_name: example-stack
template_file: cloudformation_template.json
tasks:
- name: Create CloudFormation stack
amazon.aws.cloudformation:
stack_name: "{{ stack_name }}"
state: present
region: "{{ aws_region }}"
template_body: "{{ lookup('file', template_file) }}"
template_parameters:
KeyName: my-key-pair
InstanceType: t2.micro
tags:
Stack: "{{ stack_name }}"
Environment: Development
register: cf_result
tags:
- create
- name: Display CloudFormation stack result
debug:
var: cf_result
tags:
- create
- name: Get CloudFormation stack information
amazon.aws.cloudformation_info:
stack_name: "{{ stack_name }}"
region: "{{ aws_region }}"
register: cf_info
tags:
- info
- name: Display CloudFormation stack information
debug:
var: cf_info
tags:
- info
- name: Delete CloudFormation stack
amazon.aws.cloudformation:
stack_name: "{{ stack_name }}"
state: absent
region: "{{ aws_region }}"
register: cf_delete
tags:
- delete
- name: Display CloudFormation stack deletion result
debug:
var: cf_delete
tags:
- delete