Last active
July 26, 2016 19:02
-
-
Save conleym/8815513d20ad437311366bbf533f0ceb to your computer and use it in GitHub Desktop.
Tasks to find the default VPC and its subnets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Find default VPC for region | |
command: "aws ec2 describe-vpcs --region={{ region }} --output=json --filters=Name=isDefault,Values=true --query=Vpcs[0].VpcId" | |
register: default_vpc | |
- name: Set default_vpc_id fact | |
set_fact: | |
default_vpc_id: "{{ default_vpc.stdout | from_json }}" | |
- name: Find availability zones in the default VPC | |
ec2_vpc_subnet_facts: | |
region: "{{ region }}" | |
filters: | |
defaultForAz: "true" | |
state: "available" | |
vpc-id: "{{ default_vpc_id }}" | |
register: default_subnets | |
- name: Set subnet_ids fact | |
set_fact: | |
subnet_ids: "{{ default_subnets.subnets | map(attribute='id') | list }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment