CloudWiki
Resource

VPC

Amazon Web Services
Network
A virtual private cloud (VPC) is a logical isolated and secured private cloud within a public cloud that allows you to completely control over your virtual networking environment. A VPC combines the convenience and scalability of public cloud computing with the data isolation of private cloud computing.
Terraform Name
terraform
aws_vpc
VPC
attributes:
  • cidr_block - (Optional) The IPv4 CIDR block for the VPC. CIDR can be explicitly set or it can be derived from IPAM using ipv4_netmask_length.
  • instance_tenancy - (Optional) A tenancy option for instances launched into the VPC. Default is default, which ensures that EC2 instances launched in this VPC use the EC2 instance tenancy attribute specified when the EC2 instance is launched. The only other option is dedicated, which ensures that EC2 instances launched in this VPC are run on dedicated tenancy instances regardless of the tenancy attribute specified at launch. This has a dedicated per region fee of $2 per hour, plus an hourly per instance usage fee.
  • ipv4_ipam_pool_id - (Optional) The ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR. IPAM is a VPC feature that you can use to automate your IP address management workflows including assigning, tracking, troubleshooting, and auditing IP addresses across AWS Regions and accounts. Using IPAM you can monitor IP address usage throughout your AWS Organization.
  • ipv4_netmask_length - (Optional) The netmask length of the IPv4 CIDR you want to allocate to this VPC. Requires specifying a ipv4_ipam_pool_id.
  • ipv6_cidr_block - (Optional) IPv6 CIDR block to request from an IPAM Pool. Can be set explicitly or derived from IPAM using ipv6_netmask_length.
  • ipv6_ipam_pool_id - (Optional) IPAM Pool ID for a IPv6 pool. Conflicts with assign_generated_ipv6_cidr_block.
  • ipv6_netmask_length - (Optional) Netmask length to request from IPAM Pool. Conflicts with ipv6_cidr_block. This can be omitted if IPAM pool as a allocation_default_netmask_length set. Valid values: 56.
  • ipv6_cidr_block_network_border_group - (Optional) By default when an IPv6 CIDR is assigned to a VPC a default ipv6_cidr_block_network_border_group will be set to the region of the VPC. This can be changed to restrict advertisement of public addresses to specific Network Border Groups such as LocalZones.
  • enable_dns_support - (Optional) A boolean flag to enable/disable DNS support in the VPC. Defaults to true.
  • enable_network_address_usage_metrics - (Optional) Indicates whether Network Address Usage metrics are enabled for your VPC. Defaults to false.
  • enable_dns_hostnames - (Optional) A boolean flag to enable/disable DNS hostnames in the VPC. Defaults false.
  • enable_classiclink - (Optional) A boolean flag to enable/disable ClassicLink for the VPC. Only valid in regions and accounts that support EC2 Classic. See the ClassicLink documentation for more information. Defaults false.
  • enable_classiclink_dns_support - (Optional) A boolean flag to enable/disable ClassicLink DNS Support for the VPC. Only valid in regions and accounts that support EC2 Classic.
  • assign_generated_ipv6_cidr_block - (Optional) Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You cannot specify the range of IP addresses, or the size of the CIDR block. Default is false. Conflicts with ipv6_ipam_pool_id
  • tags - (Optional) A map of tags to assign to the resource. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Associating resources with a
VPC
Resources do not "belong" to a
VPC
Rather, one or more Security Groups are associated to a resource.
Create
VPC
via Terraform:
The following HCL creates a VPC with a default tenancy option for instances launched into the VPC
Syntax:

resource "aws_vpc" "main" {
 cidr_block       = "10.0.0.0/16"
 instance_tenancy = "default"

 tags = {
   Name = "main"
 }
}

Create
VPC
via CLI:
Parameters:

create-vpc
[--cidr-block <value>]
[--amazon-provided-ipv6-cidr-block | --no-amazon-provided-ipv6-cidr-block]
[--ipv6-pool <value>]
[--ipv6-cidr-block <value>]
[--ipv4-ipam-pool-id <value>]
[--ipv4-netmask-length <value>]
[--ipv6-ipam-pool-id <value>]
[--ipv6-netmask-length <value>]
[--dry-run | --no-dry-run]
[--instance-tenancy <value>]
[--ipv6-cidr-block-network-border-group <value>]
[--tag-specifications <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]

Example:

aws ec2 create-vpc \
   --cidr-block 10.0.0.0/16 \
   --tag-specification ResourceType=vpc,Tags=[{Key=Name,Value=MyVpc}]

aws cost
Costs
The cost of using VPC depends on the number of Elastic IP addresses, Elastic Network Interfaces, Security Groups, Subnets, and the amount of data processed. Basic data transfer costs for VPC start at $0.01 per GB and decrease as the amount of data processed increases.
Direct Cost

--

Best Practices for
VPC

Categorized by Availability, Security & Compliance and Cost

Low
Access allowed from VPN
No items found.
Low
Auto Scaling Group not in use
No items found.
Medium
Connections towards DynamoDB should be via VPC endpoints
No items found.
Medium
Container in CrashLoopBackOff state
No items found.
Low
EC2 with GPU capabilities
No items found.
Medium
EC2 with high privileged policies
No items found.
Medium
ECS cluster delete alarm
No items found.
Critical
ECS task with Admin access (*:*)
Medium
ECS task with high privileged policies
No items found.
Critical
EKS cluster delete alarm
No items found.
Medium
ElastiCache cluster delete alarm
No items found.
Medium
Ensure Container liveness probe is configured
No items found.
Medium
Ensure ECS task definition has memory limit
No items found.
Critical
Ensure EMR cluster master nodes are not publicly accessible
No items found.
More from
Amazon Web Services