Class VpcProps.Builder

java.lang.Object
software.amazon.awscdk.services.ec2.VpcProps.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<VpcProps>
Enclosing interface:
VpcProps

@Stability(Stable) public static final class VpcProps.Builder extends Object implements software.amazon.jsii.Builder<VpcProps>
A builder for VpcProps
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • availabilityZones

      @Stability(Stable) public VpcProps.Builder availabilityZones(List<String> availabilityZones)
      Parameters:
      availabilityZones - Availability zones this VPC spans. Specify this option only if you do not specify maxAzs.
      Returns:
      this
    • cidr

      @Stability(Deprecated) @Deprecated public VpcProps.Builder cidr(String cidr)
      Deprecated.
      Use ipAddresses instead
      Sets the value of VpcProps.getCidr()
      Parameters:
      cidr - The CIDR range to use for the VPC, e.g. '10.0.0.0/16'. Should be a minimum of /28 and maximum size of /16. The range will be split across all subnets per Availability Zone.
      Returns:
      this
    • createInternetGateway

      @Stability(Stable) public VpcProps.Builder createInternetGateway(Boolean createInternetGateway)
      Parameters:
      createInternetGateway - If set to false then disable the creation of the default internet gateway.
      Returns:
      this
    • defaultInstanceTenancy

      @Stability(Stable) public VpcProps.Builder defaultInstanceTenancy(DefaultInstanceTenancy defaultInstanceTenancy)
      Parameters:
      defaultInstanceTenancy - The default tenancy of instances launched into the VPC. 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.
      Returns:
      this
    • enableDnsHostnames

      @Stability(Stable) public VpcProps.Builder enableDnsHostnames(Boolean enableDnsHostnames)
      Parameters:
      enableDnsHostnames - Indicates whether the instances launched in the VPC get public DNS hostnames. If this attribute is true, instances in the VPC get public DNS hostnames, but only if the enableDnsSupport attribute is also set to true.
      Returns:
      this
    • enableDnsSupport

      @Stability(Stable) public VpcProps.Builder enableDnsSupport(Boolean enableDnsSupport)
      Parameters:
      enableDnsSupport - Indicates whether the DNS resolution is supported for the VPC. 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.
      Returns:
      this
    • flowLogs

      @Stability(Stable) public VpcProps.Builder flowLogs(Map<String,? extends FlowLogOptions> flowLogs)
      Sets the value of VpcProps.getFlowLogs()
      Parameters:
      flowLogs - Flow logs to add to this VPC.
      Returns:
      this
    • gatewayEndpoints

      @Stability(Stable) public VpcProps.Builder gatewayEndpoints(Map<String,? extends GatewayVpcEndpointOptions> gatewayEndpoints)
      Parameters:
      gatewayEndpoints - Gateway endpoints to add to this VPC.
      Returns:
      this
    • ipAddresses

      @Stability(Stable) public VpcProps.Builder ipAddresses(IIpAddresses ipAddresses)
      Sets the value of VpcProps.getIpAddresses()
      Parameters:
      ipAddresses - The Provider to use to allocate IPv4 Space to your VPC. Options include static allocation or from a pool.

      Note this is specific to IPv4 addresses.

      Returns:
      this
    • ipProtocol

      @Stability(Stable) public VpcProps.Builder ipProtocol(IpProtocol ipProtocol)
      Sets the value of VpcProps.getIpProtocol()
      Parameters:
      ipProtocol - The protocol of the vpc. Options are IPv4 only or dual stack.
      Returns:
      this
    • ipv6Addresses

      @Stability(Stable) public VpcProps.Builder ipv6Addresses(IIpv6Addresses ipv6Addresses)
      Sets the value of VpcProps.getIpv6Addresses()
      Parameters:
      ipv6Addresses - The Provider to use to allocate IPv6 Space to your VPC. Options include amazon provided CIDR block.

      Note this is specific to IPv6 addresses.

      Returns:
      this
    • maxAzs

      @Stability(Stable) public VpcProps.Builder maxAzs(Number maxAzs)
      Sets the value of VpcProps.getMaxAzs()
      Parameters:
      maxAzs - Define the maximum number of AZs to use in this region. 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.

      Returns:
      this
    • natGatewayProvider

      @Stability(Stable) public VpcProps.Builder natGatewayProvider(NatProvider natGatewayProvider)
      Parameters:
      natGatewayProvider - What type of NAT provider to use. Select between NAT gateways or NAT instances. NAT gateways may not be available in all AWS regions.
      Returns:
      this
    • natGateways

      @Stability(Stable) public VpcProps.Builder natGateways(Number natGateways)
      Sets the value of VpcProps.getNatGateways()
      Parameters:
      natGateways - The number of NAT Gateways/Instances to create. 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.

      Returns:
      this
    • natGatewaySubnets

      @Stability(Stable) public VpcProps.Builder natGatewaySubnets(SubnetSelection natGatewaySubnets)
      Parameters:
      natGatewaySubnets - Configures the subnets which will have NAT Gateways/Instances. 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.

      Returns:
      this
    • reservedAzs

      @Stability(Stable) public VpcProps.Builder reservedAzs(Number reservedAzs)
      Sets the value of VpcProps.getReservedAzs()
      Parameters:
      reservedAzs - Define the number of AZs to reserve. When specified, the IP space is reserved for the azs but no actual resources are provisioned.
      Returns:
      this
    • restrictDefaultSecurityGroup

      @Stability(Stable) public VpcProps.Builder restrictDefaultSecurityGroup(Boolean restrictDefaultSecurityGroup)
      Parameters:
      restrictDefaultSecurityGroup - If set to true then the default inbound & outbound rules will be removed from the default security group.
      Returns:
      this
    • subnetConfiguration

      @Stability(Stable) public VpcProps.Builder subnetConfiguration(List<? extends SubnetConfiguration> subnetConfiguration)
      Parameters:
      subnetConfiguration - Configure the subnets to build for each AZ. 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:

                                  Vpc.Builder.create(this, "VPC")
                                          .subnetConfiguration(List.of(SubnetConfiguration.builder()
                                                  .cidrMask(24)
                                                  .name("ingress")
                                                  .subnetType(SubnetType.PUBLIC)
                                                  .build(), SubnetConfiguration.builder()
                                                  .cidrMask(24)
                                                  .name("application")
                                                  .subnetType(SubnetType.PRIVATE_WITH_EGRESS)
                                                  .build(), SubnetConfiguration.builder()
                                                  .cidrMask(28)
                                                  .name("rds")
                                                  .subnetType(SubnetType.PRIVATE_ISOLATED)
                                                  .build()))
                                          .build();
                                  
      Returns:
      this
    • vpcName

      @Stability(Stable) public VpcProps.Builder vpcName(String vpcName)
      Sets the value of VpcProps.getVpcName()
      Parameters:
      vpcName - The VPC name. Since the VPC resource doesn't support providing a physical name, the value provided here will be recorded in the Name tag
      Returns:
      this
    • vpnConnections

      @Stability(Stable) public VpcProps.Builder vpnConnections(Map<String,? extends VpnConnectionOptions> vpnConnections)
      Parameters:
      vpnConnections - VPN connections to this VPC.
      Returns:
      this
    • vpnGateway

      @Stability(Stable) public VpcProps.Builder vpnGateway(Boolean vpnGateway)
      Sets the value of VpcProps.getVpnGateway()
      Parameters:
      vpnGateway - Indicates whether a VPN gateway should be created and attached to this VPC.
      Returns:
      this
    • vpnGatewayAsn

      @Stability(Stable) public VpcProps.Builder vpnGatewayAsn(Number vpnGatewayAsn)
      Sets the value of VpcProps.getVpnGatewayAsn()
      Parameters:
      vpnGatewayAsn - The private Autonomous System Number (ASN) for the VPN gateway.
      Returns:
      this
    • vpnRoutePropagation

      @Stability(Stable) public VpcProps.Builder vpnRoutePropagation(List<? extends SubnetSelection> vpnRoutePropagation)
      Parameters:
      vpnRoutePropagation - Where to propagate VPN routes.
      Returns:
      this
    • build

      @Stability(Stable) public VpcProps build()
      Builds the configured instance.
      Specified by:
      build in interface software.amazon.jsii.Builder<VpcProps>
      Returns:
      a new instance of VpcProps
      Throws:
      NullPointerException - if any required attribute was not provided