Resource: aws_vpc#
Manages a VPC. For more information, see the documentation on VPC.
Example Usage#
Basic usage:
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
Basic usage with tags:
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "main"
}
}
Argument Reference#
The following arguments are supported:
cidr_block- (Optional) The IPv4 CIDR block for the VPC.enable_dns_support- (Optional) A boolean flag to enable/disable DNS support in the VPC. Defaults true.tags- (Optional) Map of tags to assign to the VPC. If a providerdefault_tagsconfiguration block is used, tags with matching keys will overwrite those defined at the provider level.
Attribute Reference#
Supported attributes#
In addition to all arguments above, the following attributes are exported:
arn- The Amazon Resource Name (ARN) of the VPC.id- The ID of the VPC.main_route_table_id- The ID of the main route table associated with this VPC. Note that you can change a VPC's main route table by using anaws_main_route_table_association.default_network_acl_id- The ID of the network ACL created by default on VPC creation.default_security_group_id- The ID of the security group created by default on VPC creation.default_route_table_id- The ID of the route table created by default on VPC creation.tags_all- Map of tags assigned to the VPC, including those inherited from the providerdefault_tagsconfiguration block.
Unsupported attributes#
~> Note These attributes may be present in the terraform.tfstate file, but they have preset values and cannot be specified in configuration files.
The following attributes are not currently supported:
assign_generated_ipv6_cidr_block, enable_classiclink, enable_classiclink_dns_support, enable_dns_hostnames, instance_tenancy, ipv4_ipam_pool_id, ipv4_netmask_length, ipv6_association_id, ipv6_cidr_block, ipv6_cidr_block_network_border_group, ipv6_ipam_pool_id, ipv6_netmask_length, owner_id.
Import#
VPCs can be imported using the vpc id, e.g.,
$ terraform import aws_vpc.test_vpc vpc-12345678