Skip to content

10._Subnets

Ahmad Abdo edited this page Jun 26, 2017 · 1 revision

Subnets

Default Subnet Classes

The public and private Subnet class specifies the CIDR and options to create both an Internet Gateway and NAT Gateway. The name, VPC, IP, and AZ (optional) are provided during the command execution.

awsm Public Subnet Class - Screenshot

awsm Private Subnet Class - Screenshot




listSubnets


Usage

$ awsm listSubnets --help
NAME:
   awsm listSubnets - List Subnets

USAGE:
   awsm listSubnets [arguments...]

ARGUMENTS:
   [search] - The keyword to search for

Example Output

awsm listSubnets awsm

This will list all Subnets matching the search term public, the output should look similar to this:

$ awsm listSubnets public
+--------+--------+-----------------+---------------+--------------+-----------+-------------------+---------+-------------+---------------+---------------+-----------+
|  NAME  | CLASS  |    SUBNET ID    |   VPC NAME    |    VPC ID    |   STATE   | AVAILABILITY ZONE | DEFAULT | CIDR BLOCK  | AVAILABLE IPS | MAP PUBLIC IP |  REGION   |
+--------+--------+-----------------+---------------+--------------+-----------+-------------------+---------+-------------+---------------+---------------+-----------+
| Public | public | subnet-016a5f75 | us-west-2-vpc | vpc-551c1637 | available | us-west-2a        | false   | 10.0.1.0/24 |           240 | false         | us-west-2 |
| Public | public | subnet-bdb5efd0 | us-east-1-vpc | vpc-abb5efc6 | available | us-east-1a        | false   | 10.1.1.0/24 |           239 | false         | us-east-1 |
| Public | public | subnet-3a552552 | eu-west-1-vpc | vpc-20552548 | available | eu-west-1a        | false   | 10.2.1.0/24 |           246 | false         | eu-west-1 |
+--------+--------+-----------------+---------------+--------------+-----------+-------------------+---------+-------------+---------------+---------------+-----------+



createSubnet


Usage

$ awsm createSubnet --help

NAME:
   awsm createSubnet - Create a VPC Subnet

USAGE:
   awsm createSubnet [arguments...]

ARGUMENTS:
   class - The class of Subnet to create
   name - The name of the Subnet
   vpc - The VPC to create the Subnet in
   ip - The IP address of this Subnet (not including CIDR)
   [az] - The Availability Zone to create the Subnet in

Example Output

awsm createSubnet public awsm-public awsm-vpc 10.1.1.0 us-east-1a

This will create a new Subnet named awsm-public with the CIDR IP range of 10.1.1.0/24 in the awsm-vpc VPC.

It also creates an Internet Gateway, a NAT Gateway with an Elastic IP, and new Route Table.

The output should look similar to this:

$ awsm createSubnet public awsm-public awsm-vpc 10.1.1.0 us-east-1a

✓  Found Subnet Class Configuration for [public]!

✓  Found VPC [vpc-d144a4a8] named [awsm-vpc] with a class of [awsm] in [us-east-1]!

△  Created Subnet [subnet-63173406] named [awsm-public] in [us-east-1]!

▶  Waiting to tag Subnet...

△  Adding Subnet Tags...

▶  Creating a new Internet Gateway...

△  Created VPC Internet Gateway [igw-1272ab74] named [awsm-vpc-internet-gateway] in [us-east-1]!

△  Adding Internet Gateway Tags...

▶  Attaching Internet Gateway to VPC...

△  Attached Internet Gateway [igw-1272ab74] to VPC [vpc-d144a4a8]!

▶  Creating a new Route Table...

△  Created VPC Route Table [rtb-8003ebf8] named [awsm-vpc-awsm-public-route-table] in [us-east-1]!

▶  Associating Route Table to Subnet...

△  Associated Route Table [rtb-8003ebf8] to Subnet [subnet-63173406] !

▶  Adding Internet Gateway to New Route Table...

△  Added route to [rtb-8003ebf8]!

▶  Creating a new NAT Gateway...

△  Created Address [34.239.229.218] with allocation Id [eipalloc-65073554] in [us-east-1]!

△  Created VPC NAT Gateway [nat-08e2c09e999caeffe] named [awsm-vpc-nat-gateway] in [us-east-1]!

▶  Waiting until the NAT Gateway is available...

▶  Adding NAT Gateway to Main Route Table...

△  Added route to [rtb-7abd5402]!

✓  Done!



deleteSubnets


Usage

$ awsm deleteSubnets --help
Incorrect Usage.

NAME:
   awsm deleteSubnets - Delete VPC Subnets

USAGE:
   awsm deleteSubnets [arguments...]

ARGUMENTS:
   search - The search term for Subnets to delete
   [region] - The region of the subnets (optional)

Example Output

awsm deleteSubnets 016a5f75

This will delete Subnets matching the search term 016a5f75, the output should look similar to this:

$ awsm deleteSubnets 016a5f75

✓  --dry-run flag is set, not making any actual changes!                                               
+--------+--------+-----------------+---------------+--------------+-----------+-------------------+---------+-------------+---------------+---------------+-----------+
|  NAME  | CLASS  |    SUBNET ID    |   VPC NAME    |    VPC ID    |   STATE   | AVAILABILITY ZONE | DEFAULT | CIDR BLOCK  | AVAILABLE IPS | MAP PUBLIC IP |  REGION   |
+--------+--------+-----------------+---------------+--------------+-----------+-------------------+---------+-------------+---------------+---------------+-----------+
| Public | public | subnet-016a5f75 | us-west-2-vpc | vpc-551c1637 | available | us-west-2a        | false   | 10.0.1.0/24 |           240 | false         | us-west-2 |
+--------+--------+-----------------+---------------+--------------+-----------+-------------------+---------+-------------+---------------+---------------+-----------+

▶  Are you sure you want to delete these Subnets?                                                      
◀  y

△  Deleted Subnet [Public] in region [us-west-2]!