Skip to content

Commit 0a2df0b

Browse files
author
Tom Bamford
committed
Usage example for subnet_ids
1 parent f39d059 commit 0a2df0b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ subnet_ids:
156156
- subnet-aabbcc35
157157
```
158158
159+
Which you can reference like this:
160+
161+
```yaml
162+
- hosts: localhost
163+
connection: local
164+
tasks:
165+
- ec2:
166+
instance_type: t2.micro
167+
vpc_subnet_id: "{{ subnet_ids['us-east-1']['manhattan']['stage']['app'] | random }}"
168+
state: present
169+
```
170+
159171
The same pattern is implemented for VPCs, subnets, security groups and ELB target groups, alowing you to specify and target resources in your playbooks without hard coding resource IDs, without using `*_facts` modules everywhere, and without needing to know the exact names of every resource. It's important to note that these resources can reside in any number of AWS accounts, as long as they can be reached by your Ansible control host.
160172

161173

0 commit comments

Comments
 (0)