I am able to create VPCs in AWS using salt states, using boto.vpc. But I also need to create create (in addition to the VPC itself) subnets, internet gateways, route tables based on the original VPC that I'm able to create.
So if the VPC definition looks like this:
Create VPC:
boto_vpc.present:
- name: dlab-new
- cidr_block: 10.0.0.1/24
- dns_hostnames: True
- region: us-east-1
- keyid: keyid
- key: key
How can I refer to the original VPC in subsequent parts of the VPC config? Since I won't know the vpc_id of the VPC until it's created. Is there a variable I could use in subsequent definitions of subnets, IGWs and route tables using a variable?
Create subnet:
boto_vpc.subnet_present:
- name: dlab-new-subnet
- vpc_id: ?????
- cidr_block: 10.0.0.1/24
- region: us-east-1
- keyid: keyid
- key: key
Create internet gateway:
boto_vpc.internet_gateway_present:
- name: dlab-igw
- vpc_name: ????
- keyid: keyid
- key: key
Create route:
boto_vpc.route_table_present:
- name: my_route_table
- vpc_id: ???
- routes:
- destination_cidr_block: 10.0.0.1/24
instance_id: i-123456
- subnet_names:
- dlab-new-subnet
- region: us-east-1
- profile:
keyid: keyid
key: key
Is there any way to use a variable in place of the - vpc_id value that would allow the definitions for subnet, IGW etc to get the name of the VPC generated by the Create VPC process?
You can now use "vpc_name" for boto_vpc.subnet_present. You don't need to use "vpc_id" at least as of version salt 2016.11.3 (Carbon)