aws ec2 create-vpc
Creates a VPC with the specified CIDR blocks. AWS CLI reference
4 examples 13 options Its page in the AWS CLI reference
Examples
Example 1: To create a VPC
The following create-vpc example creates a VPC with the specified IPv4 CIDR block and a Name tag.
aws ec2 create-vpc --cidr-block 10.0.0.0/16 --tag-specifications ResourceType=vpc,Tags=[{Key=Name,Value=MyVpc}]Identify--cidr-blockThe IPv4 network range for the VPC, in CIDR notation.--tag-specificationsThe tags to assign to the VPC.Its output
{
"Vpc": {
"CidrBlock": "10.0.0.0/16",
"DhcpOptionsId": "dopt-5EXAMPLE",
"State": "pending",
"VpcId": "vpc-0a60eb65b4EXAMPLE",
"OwnerId": "123456789012",
"InstanceTenancy": "default",
"Ipv6CidrBlockAssociationSet": [],
"CidrBlockAssociationSet": [
{
"AssociationId": "vpc-cidr-assoc-07501b79ecEXAMPLE",
"CidrBlock": "10.0.0.0/16",
"CidrBlockState": {
"State": "associated"
}
}
],
"IsDefault": false,
"Tags": [
{
"Key": "Name",
"Value": "MyVpc"
}
]
}
}Example 2: To create a VPC with dedicated tenancy
The following create-vpc example creates a VPC with the specified IPv4 CIDR block and dedicated tenancy.
aws ec2 create-vpc --cidr-block 10.0.0.0/16 --instance-tenancy dedicatedIdentify--cidr-blockThe IPv4 network range for the VPC, in CIDR notation.--instance-tenancyThe tenancy options for instances launched into the VPC.Its output
{
"Vpc": {
"CidrBlock": "10.0.0.0/16",
"DhcpOptionsId": "dopt-19edf471",
"State": "pending",
"VpcId": "vpc-0a53287fa4EXAMPLE",
"OwnerId": "123456789012",
"InstanceTenancy": "dedicated",
"Ipv6CidrBlockAssociationSet": [],
"CidrBlockAssociationSet": [
{
"AssociationId": "vpc-cidr-assoc-00b24cc1c2EXAMPLE",
"CidrBlock": "10.0.0.0/16",
"CidrBlockState": {
"State": "associated"
}
}
],
"IsDefault": false
}
}Example 3: To create a VPC with an IPv6 CIDR block
The following create-vpc example creates a VPC with an Amazon-provided IPv6 CIDR block.
aws ec2 create-vpc --cidr-block 10.0.0.0/16 --amazon-provided-ipv6-cidr-blockIdentify--cidr-blockThe IPv4 network range for the VPC, in CIDR notation.--amazon-provided-ipv6-cidr-blockRequests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC.Its output, shortened
{
"Vpc": {
"CidrBlock": "10.0.0.0/16",
"DhcpOptionsId": "dopt-dEXAMPLE",
"State": "pending",
"VpcId": "vpc-0fc5e3406bEXAMPLE",
"OwnerId": "123456789012",
"InstanceTenancy": "default",
"Ipv6CidrBlockAssociationSet": [
{
"AssociationId": "vpc-cidr-assoc-068432c60bEXAMPLE",
"Ipv6CidrBlock": "",
"Ipv6CidrBlockState": {
"State": "associating"
},
"Ipv6Pool": "Amazon",
"NetworkBorderGroup": "us-west-2"
}
],
"CidrBlockAssociationSet": [
{
"AssociationId": "vpc-cidr-assoc-0669f8f9f5EXAMPLE",
"CidrBlock": "10.0.0.0/16",
"CidrBlockState": {
"State": "associated"
}
}
],
"IsDefault": false
}
… 1 more lineExample 4: To create a VPC with a CIDR from an IPAM pool
The following create-vpc example creates a VPC with a CIDR from an Amazon VPC IP Address Manager (IPAM) pool.
For Linux and macOS, use the following command.
aws ec2 create-vpc --ipv4-ipam-pool-id ipam-pool-0533048da7d823723 --tag-specifications ResourceType=vpc,Tags='[{Key=Environment,Value="Preprod"},{Key=Owner,Value="Build Team"}]'Identify--ipv4-ipam-pool-idThe ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR.--tag-specificationsThe tags to assign to the VPC.For Windows, use the following command.
aws ec2 create-vpc ^Identify--ipv4-ipam-pool-id ipam-pool-0533048da7d823723 ^--tag-specifications ResourceType=vpc,Tags=[{Key=Environment,Value="Preprod"},{Key=Owner,Value="Build Team"}]Its output, shortened
{
"Vpc": {
"CidrBlock": "10.0.1.0/24",
"DhcpOptionsId": "dopt-2afccf50",
"State": "pending",
"VpcId": "vpc-010e1791024eb0af9",
"OwnerId": "123456789012",
"InstanceTenancy": "default",
"Ipv6CidrBlockAssociationSet": [],
"CidrBlockAssociationSet": [
{
"AssociationId": "vpc-cidr-assoc-0a77de1d803226d4b",
"CidrBlock": "10.0.1.0/24",
"CidrBlockState": {
"State": "associated"
}
}
],
"IsDefault": false,
"Tags": [
{
"Key": "Environment",
"Value": "Preprod"
},
{
"Key": "Owner",
"Value": "Build Team"
}
]
}
… 1 more lineFor more information, see Create a VPC that uses an IPAM pool CIDR in the Amazon VPC IPAM User Guide.
Options
--amazon-provided-ipv6-cidr-blockRequests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC.--cidr-blockThe IPv4 network range for the VPC, in CIDR notation.--dry-runChecks whether you have the required permissions for the action, without actually making the request, and provides an error response.--instance-tenancyThe tenancy options for instances launched into the VPC.--ipv4-ipam-pool-idThe ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR.--ipv4-netmask-lengthThe netmask length of the IPv4 CIDR you want to allocate to this VPC from an Amazon VPC IP Address Manager (IPAM) pool.--ipv6-cidr-block-network-border-groupThe name of the location from which we advertise the IPV6 CIDR block.--ipv6-cidr-blockThe IPv6 CIDR block from the IPv6 address pool.--ipv6-ipam-pool-idThe ID of an IPv6 IPAM pool which will be used to allocate this VPC an IPv6 CIDR.--ipv6-netmask-lengthThe netmask length of the IPv6 CIDR you want to allocate to this VPC from an Amazon VPC IP Address Manager (IPAM) pool.--ipv6-poolThe ID of an IPv6 address pool from which to allocate the IPv6 CIDR block.--tag-specificationsThe tags to assign to the VPC.--vpc-encryption-controlSpecifies the encryption control configuration to apply to the VPC during creation.