Specifies a virtual private cloud (VPC). You can optionally request an IPv6 CIDR block for the VPC. You can request an Amazon-provided IPv6 CIDR block from Amazon's pool of IPv6 addresses, or an IPv6 CIDR block from an IPv6 address pool that you provisioned through bring your own IP addresses (BYOIP). For more information, see Virtual private clouds (VPC) in the Amazon VPC User Guide.
To create a VPC
resource "awscc_ec2_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
To create a VPC with tags
resource "awscc_ec2_vpc" "main" {
cidr_block = "10.0.0.0/16"
instance_tenancy = "default"
tags = [{
key = "Name"
value = "main"
}]
}
To create a VPC with CIDR from AWS IPAM
resource "awscc_ec2_ipam" "main" {
operating_regions = [{
region_name = "us-east-1"
}]
}
resource "awscc_ec2_ipam_pool" "main" {
address_family = "ipv4"
ipam_scope_id = awscc_ec2_ipam.main.private_default_scope_id
locale = "us-east-1"
}
resource "awscc_ec2_ipam_pool_cidr" "main" {
ipam_pool_id = awscc_ec2_ipam_pool.main.id
cidr = "10.0.0.0/16"
}
resource "awscc_ec2_vpc" "main" {
ipv_4_ipam_pool_id = awscc_ec2_ipam_pool.main.id
ipv_4_netmask_length = 20
depends_on = [
awscc_ec2_ipam_pool_cidr.main
]
}
Create a VPC with Amazon provided IPV6 pool
resource "awscc_ec2_vpc_cidr_block" "main" {
amazon_provided_ipv_6_cidr_block = true
vpc_id = awscc_ec2_vpc.selected.id
}
resource "awscc_ec2_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
cidr_block
(String) The IPv4 network range for the VPC, in CIDR notation. For example, 10.0.0.0/16
. We modify the specified CIDR block to its canonical form; for example, if you specify 100.68.0.18/18
, we modify it to 100.68.0.0/18
.
You must specify eitherCidrBlock
or Ipv4IpamPoolId
.enable_dns_hostnames
(Boolean) Indicates whether the instances launched in the VPC get DNS hostnames. If enabled, instances in the VPC get DNS hostnames; otherwise, they do not. Disabled by default for nondefault VPCs. For more information, see DNS attributes in your VPC.
You can only enable DNS hostnames if you've enabled DNS support.enable_dns_support
(Boolean) Indicates whether the DNS resolution is supported for the VPC. If enabled, queries to the Amazon provided DNS server at the 169.254.169.253 IP address, or the reserved IP address at the base of the VPC network range "plus two" succeed. If disabled, the Amazon provided DNS service in the VPC that resolves public DNS hostnames to IP addresses is not enabled. Enabled by default. For more information, see DNS attributes in your VPC.instance_tenancy
(String) The allowed tenancy of instances launched into the VPC.
default
: An instance launched into the VPC runs on shared hardware by default, unless you explicitly specify a different tenancy during instance launch.dedicated
: An instance launched into the VPC runs on dedicated hardware by default, unless you explicitly specify a tenancy of host
during instance launch. You cannot specify a tenancy of default
during instance launch.Updating InstanceTenancy
requires no replacement only if you are updating its value from dedicated
to default
. Updating InstanceTenancy
from default
to dedicated
requires replacement.
ipv_4_ipam_pool_id
(String) The ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR. For more information, see What is IPAM? in the Amazon VPC IPAM User Guide.
You must specify eitherCidrBlock
or Ipv4IpamPoolId
.ipv_4_netmask_length
(Number) The netmask length of the IPv4 CIDR you want to allocate to this VPC from an Amazon VPC IP Address Manager (IPAM) pool. For more information about IPAM, see What is IPAM? in the Amazon VPC IPAM User Guide.tags
(Attributes List) The tags for the VPC. (see below for nested schema)cidr_block_associations
(List of String)default_network_acl
(String)default_security_group
(String)id
(String) Uniquely identifies the resource.ipv_6_cidr_blocks
(List of String)vpc_id
(String)tags
Required:
key
(String) The tag key.value
(String) The tag value.Import is supported using the following syntax:
$ terraform import awscc_ec2_vpc.example <resource ID>