VpcProps Struct
Configuration for Vpc.
Example
import * as ec2 from 'aws-cdk-lib/aws-ec2';
const vpc = new ec2.Vpc(this, 'Vpc', {
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16')
});
const vpcConnector = new apprunner.VpcConnector(this, 'VpcConnector', {
vpc,
vpcSubnets: vpc.selectSubnets({ subnetType: ec2.SubnetType.PUBLIC }),
vpcConnectorName: 'MyVpcConnector',
});
new apprunner.Service(this, 'Service', {
source: apprunner.Source.fromEcrPublic({
imageConfiguration: { port: 8000 },
imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
}),
vpcConnector,
});
Properties
availabilityZonesoptionalstring[]availability_zonesoptionaltyping.List[str]availabilityZonesoptionalList<String>AvailabilityZonesoptionalstring[]AvailabilityZonesoptional*[]*string#Default: a subset of AZs of the stack
Specify this option only if you do not specify maxAzs.
cidroptionalstringcidroptionalstrcidroptionalStringCidroptionalstringCidroptional*string= Vpc.DEFAULT_CIDR_RANGEdeprecated#Should be a minimum of /28 and maximum size of /16. The range will be split across all subnets per Availability Zone.
createInternetGatewayoptionalbooleancreate_internet_gatewayoptionalboolcreateInternetGatewayoptionalBooleanCreateInternetGatewayoptionalboolCreateInternetGatewayoptional*bool= true#defaultInstanceTenancyoptionalDefaultInstanceTenancydefault_instance_tenancyoptionalDefaultInstanceTenancydefaultInstanceTenancyoptionalDefaultInstanceTenancyDefaultInstanceTenancyoptionalDefaultInstanceTenancyDefaultInstanceTenancyoptionalDefaultInstanceTenancy#Default: DefaultInstanceTenancy.Default (shared) tenancy
By setting this to dedicated tenancy, instances will be launched on hardware dedicated to a single AWS customer, unless specifically specified at instance launch time. Please note, not all instance types are usable with Dedicated tenancy.
enableDnsHostnamesoptionalbooleanenable_dns_hostnamesoptionalboolenableDnsHostnamesoptionalBooleanEnableDnsHostnamesoptionalboolEnableDnsHostnamesoptional*bool= true#If this attribute is true, instances in the VPC get public DNS hostnames, but only if the enableDnsSupport attribute is also set to true.
enableDnsSupportoptionalbooleanenable_dns_supportoptionalboolenableDnsSupportoptionalBooleanEnableDnsSupportoptionalboolEnableDnsSupportoptional*bool= true#notes
If this attribute is false, the Amazon-provided DNS server in the VPC that resolves public DNS hostnames to IP addresses is not enabled. If this attribute is true, 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 IPv4 network range plus two will succeed.
flowLogsoptional{ [key: string]: FlowLogOptions }flow_logsoptionaltyping.Mapping[str, FlowLogOptions]flowLogsoptionalMap<String, FlowLogOptions>FlowLogsoptionalIDictionary<string, FlowLogOptions>FlowLogsoptional*map[string]FlowLogOptions#Default: No flow logs.
gatewayEndpointsoptional{ [key: string]: GatewayVpcEndpointOptions }gateway_endpointsoptionaltyping.Mapping[str, GatewayVpcEndpointOptions]gatewayEndpointsoptionalMap<String, GatewayVpcEndpointOptions>GatewayEndpointsoptionalIDictionary<string, GatewayVpcEndpointOptions>GatewayEndpointsoptional*map[string]GatewayVpcEndpointOptions= None.#ipAddressesoptionalIIpAddressesip_addressesoptionalIIpAddressesipAddressesoptionalIIpAddressesIpAddressesoptionalIIpAddressesIpAddressesoptionalIIpAddresses= ec2.IpAddresses.cidr#Options include static allocation or from a pool.
Note this is specific to IPv4 addresses.
ipProtocoloptionalIpProtocolip_protocoloptionalIpProtocolipProtocoloptionalIpProtocolIpProtocoloptionalIpProtocolIpProtocoloptionalIpProtocol= IpProtocol.IPV4_ONLY#Options are IPv4 only or dual stack.
ipv6AddressesoptionalIIpv6Addressesipv6_addressesoptionalIIpv6Addressesipv6AddressesoptionalIIpv6AddressesIpv6AddressesoptionalIIpv6AddressesIpv6AddressesoptionalIIpv6Addresses= Ipv6Addresses.amazonProvided#Options include amazon provided CIDR block.
Note this is specific to IPv6 addresses.
maxAzsoptionalnumbermax_azsoptionalint | floatmaxAzsoptionalNumberMaxAzsoptionaldoubleMaxAzsoptional*float64= 3#notes
If the region has more AZs than you want to use (for example, because of EIP limits), pick a lower number here. The AZs will be sorted and picked from the start of the list.
If you pick a higher number than the number of AZs in the region, all AZs in the region will be selected. To use "all AZs" available to your account, use a high number (such as 99).
Be aware that environment-agnostic stacks will be created with access to only 2 AZs, so to use more than 2 AZs, be sure to specify the account and region on your stack.
Specify this option only if you do not specify availabilityZones.
natGatewayProvideroptionalNatProvidernat_gateway_provideroptionalNatProvidernatGatewayProvideroptionalNatProviderNatGatewayProvideroptionalNatProviderNatGatewayProvideroptionalNatProvider= NatProvider.gateway()#Select between NAT gateways or NAT instances. NAT gateways may not be available in all AWS regions.
natGatewaysoptionalnumbernat_gatewaysoptionalint | floatnatGatewaysoptionalNumberNatGatewaysoptionaldoubleNatGatewaysoptional*float64#Default: One NAT gateway/instance per Availability Zone
notes
The type of NAT gateway or instance will be determined by the natGatewayProvider parameter.
You can set this number lower than the number of Availability Zones in your VPC in order to save on NAT cost. Be aware you may be charged for cross-AZ data traffic instead.
natGatewaySubnetsoptionalSubnetSelectionnat_gateway_subnetsoptionalSubnetSelectionnatGatewaySubnetsoptionalSubnetSelectionNatGatewaySubnetsoptionalSubnetSelectionNatGatewaySubnetsoptionalSubnetSelection#Default: All public subnets.
You can pick a specific group of subnets by specifying the group name; the picked subnets must be public subnets.
Only necessary if you have more than one public subnet group.
reservedAzsoptionalnumberreserved_azsoptionalint | floatreservedAzsoptionalNumberReservedAzsoptionaldoubleReservedAzsoptional*float64= 0#When specified, the IP space is reserved for the azs but no actual resources are provisioned.
restrictDefaultSecurityGroupoptionalbooleanrestrict_default_security_groupoptionalboolrestrictDefaultSecurityGroupoptionalBooleanRestrictDefaultSecurityGroupoptionalboolRestrictDefaultSecurityGroupoptional*bool#Default: true if '@aws-cdk/aws-ec2:restrictDefaultSecurityGroup' is enabled, false otherwise
subnetConfigurationoptionalSubnetConfiguration[]subnet_configurationoptionaltyping.List[SubnetConfiguration]subnetConfigurationoptionalList<SubnetConfiguration>SubnetConfigurationoptionalSubnetConfiguration[]SubnetConfigurationoptional*[]SubnetConfiguration#Default: The VPC CIDR will be evenly divided between 1 public and 1 private subnet per AZ.
notes
Each entry in this list configures a Subnet Group; each group will contain a subnet for each Availability Zone.
For example, if you want 1 public subnet, 1 private subnet, and 1 isolated subnet in each AZ provide the following:
new ec2.Vpc(this, 'VPC', {
subnetConfiguration: [
{
cidrMask: 24,
name: 'ingress',
subnetType: ec2.SubnetType.PUBLIC,
},
{
cidrMask: 24,
name: 'application',
subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
},
{
cidrMask: 28,
name: 'rds',
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
}
]
});
vpcNameoptionalstringvpc_nameoptionalstrvpcNameoptionalStringVpcNameoptionalstringVpcNameoptional*string= this.node.path#Since the VPC resource doesn't support providing a physical name, the value provided here will be recorded in the Name tag
vpnConnectionsoptional{ [key: string]: VpnConnectionOptions }vpn_connectionsoptionaltyping.Mapping[str, VpnConnectionOptions]vpnConnectionsoptionalMap<String, VpnConnectionOptions>VpnConnectionsoptionalIDictionary<string, VpnConnectionOptions>VpnConnectionsoptional*map[string]VpnConnectionOptions#Default: No connections.
vpnGatewayoptionalbooleanvpn_gatewayoptionalboolvpnGatewayoptionalBooleanVpnGatewayoptionalboolVpnGatewayoptional*bool#Default: true when vpnGatewayAsn or vpnConnections is specified
vpnGatewayAsnoptionalnumbervpn_gateway_asnoptionalint | floatvpnGatewayAsnoptionalNumberVpnGatewayAsnoptionaldoubleVpnGatewayAsnoptional*float64#Default: Amazon default ASN.
vpnRoutePropagationoptionalSubnetSelection[]vpn_route_propagationoptionaltyping.List[SubnetSelection]vpnRoutePropagationoptionalList<SubnetSelection>VpnRoutePropagationoptionalSubnetSelection[]VpnRoutePropagationoptional*[]SubnetSelection#Default: On the route tables associated with private subnets. If no private subnets exists, isolated subnets are used. If no isolated subnets exists, public subnets are used.