Open topic with navigation

# Create the Virtual Private Cloud

An VPC is a virtual network. For more information, see Amazon VPC.

- Creating the VPC

- Enabling DNS and Hostname Resolution

## Creating the VPC

To create the VPC, in the AWS CLI, run the following command:

    # aws ec2 create-vpc \
    --cidr-block <CIDR allocated for new VPC> \
    | jq -r '.Vpc.VpcId'

The command will return the new VPC's VPC ID. Record the VPC ID and VPC CIDR to the AWS worksheet.

For example below is an input and output:

    # aws ec2 create-vpc \
    --cidr-block 10.0.0.0/16 \
    | jq -r '.Vpc.VpcId'

    vpc-0143197ca9bd9c117

To (optionally) verify assigned tags:

Run the command:

    # aws ec2 describe-tags \
    --filters "Name=resource-id,Values=<VPC ID>"

For example:

    # aws ec2 describe-tags \
    --filters "Name=resource-id,Values=vpc-0143197ca9bd9c117"

    {
    			"Tags":[
    			{
    			"Key":"Name",
    			"ResourceId":"vpc-0143197ca9bd9c117",
    			"ResourceType":"vpc",
    			"Value":"srgdemo-vpc"
    			},
    			{
    			"Key":"kubernetes.io/cluster/srgdemo-cluster",
    			"ResourceId":"vpc-0143197ca9bd9c117",
    			"ResourceType":"vpc",
    			"Value":"shared"
    			}
    			]
    		}

## Enabling DNS and Hostname Resolution

DNS support and hostname resolution should be enabled to make IP addresses more easily human-readable.

To enable DNS using the web UI:

1. Using the Find Services search tool, locate and browse to the VPC dashboard.
2. On the left navigation panel, under Virtual Private Cloud, click Your VPCs.
3. Select the check box corresponding to your VPC. Then, under Actions, select Edit VPC settings.

4. On the Edit DNS Resolution page, for DNS resolution, select the enable check box.

5. Click Save, then click Close.

To enable hostname resolution using the web UI:

1. Using the Find Services search tool, locate and browse to the VPC dashboard.
2. On the left navigation panel, under Virtual Private Cloud, click Your VPCs.
3. Select the check box corresponding to your VPC. Then, under Actions, select Edit VPC settings.

4. On the Edit VPC Settings page, for DNS hostnames, select the enable check box.
5. Click Save, then click Close.

To enable DNS using the AWS CLI:

Execute the following commands in order, using the VPC ID of your created VPC:

    # aws ec2 modify-vpc-attribute \
    --vpc-id <VPC Id> \
    --enable-dns-support

    # aws ec2 modify-vpc-attribute\
     --vpc-id <VPC Id> \
    --enable-dns-hostnames

These commands have no output.

For example:

    # aws ec2 modify-vpc-attribute \
    --vpc-id vpc-0143197ca9bd9c117 \
    --enable-dns-support
    # aws ec2 modify-vpc-attribute \
    --vpc-id vpc-0143197ca9bd9c117 \
    --enable-dns-hostnames

Next Step: Create the External IP Address