Class CfnVPC

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, IVPCRef, IEnvironmentAware, ITaggable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.139.0 (build 26a6b54)", date="2026-09-02T11:03:08.579Z") @Stability(Stable) public class CfnVPC extends CfnResource implements IInspectable, IVPCRef, ITaggable
Specifies a virtual private cloud (VPC).

A VPC must have an associated IPv4 CIDR block. You can specify an IPv4 CIDR block or an IPAM-allocated IPv4 CIDR block. To associate an IPv6 CIDR block with the VPC, see AWS::EC2::VPCCidrBlock .

For more information, see Virtual private clouds (VPC) in the Amazon VPC User Guide .

Example:

 CfnInclude cfnTemplate;
 // using from*Attributes()
 CfnSubnet privateCfnSubnet1;
 CfnSubnet privateCfnSubnet2;
 // using from*Name()
 CfnBucket cfnBucket = (CfnBucket)cfnTemplate.getResource("Bucket");
 IBucket bucket = Bucket.fromBucketName(this, "L2Bucket", cfnBucket.getRef());
 // using from*Arn()
 CfnKey cfnKey = (CfnKey)cfnTemplate.getResource("Key");
 IKey key = Key.fromKeyArn(this, "L2Key", cfnKey.getAttrArn());
 CfnVPC cfnVpc = (CfnVPC)cfnTemplate.getResource("Vpc");
 IVpc vpc = Vpc.fromVpcAttributes(this, "L2Vpc", VpcAttributes.builder()
         .vpcId(cfnVpc.getRef())
         .availabilityZones(Fn.getAzs())
         .privateSubnetIds(List.of(privateCfnSubnet1.getRef(), privateCfnSubnet2.getRef()))
         .build());
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnVPC

      protected CfnVPC(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnVPC

      protected CfnVPC(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnVPC

      @Stability(Stable) public CfnVPC(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable CfnVPCProps props)
      Create a new AWS::EC2::VPC.

      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties.
    • CfnVPC

      @Stability(Stable) public CfnVPC(@NotNull software.constructs.Construct scope, @NotNull String id)
      Create a new AWS::EC2::VPC.

      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
  • Method Details

    • arnForVPC

      @Stability(Stable) @NotNull public static String arnForVPC(@NotNull IVPCRef resource)
      Parameters:
      resource - This parameter is required.
    • fromVpcId

      @Stability(Stable) @NotNull public static IVPCRef fromVpcId(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String vpcId)
      Creates a new IVPCRef from a vpcId.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      vpcId - This parameter is required.
    • isCfnVPC

      @Stability(Stable) @NotNull public static Boolean isCfnVPC(@NotNull Object x)
      Checks whether the given object is a CfnVPC.

      Parameters:
      x - This parameter is required.
    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrCidrBlock

      @Stability(Stable) @NotNull public String getAttrCidrBlock()
      The primary IPv4 CIDR block for the VPC.

      For example, 10.0.0.0/16.

    • getAttrCidrBlockAssociations

      @Stability(Stable) @NotNull public List<String> getAttrCidrBlockAssociations()
      The association IDs of the IPv4 CIDR blocks for the VPC.

      For example, [ vpc-cidr-assoc-0280ab6b ].

    • getAttrDefaultNetworkAcl

      @Stability(Stable) @NotNull public String getAttrDefaultNetworkAcl()
      The ID of the default network ACL for the VPC.

      For example, acl-814dafe3.

    • getAttrDefaultSecurityGroup

      @Stability(Stable) @NotNull public String getAttrDefaultSecurityGroup()
      The ID of the default security group for the VPC.

      For example, sg-b178e0d3.

    • getAttrIpv6CidrBlocks

      @Stability(Stable) @NotNull public List<String> getAttrIpv6CidrBlocks()
      The IPv6 CIDR blocks for the VPC.

      For example, [ 2001:db8:1234:1a00::/56 ].

    • getAttrVpcEncryptionControlResourceExclusions

      @Stability(Stable) @NotNull public IResolvable getAttrVpcEncryptionControlResourceExclusions()
      Describes the exclusion configurations for various resource types in VPC Encryption Control.

      For more information, see Enforce VPC encryption in transit in the Amazon VPC User Guide.

    • getAttrVpcEncryptionControlResourceExclusionsEgressOnlyInternetGateway

      @Stability(Stable) @NotNull public IResolvable getAttrVpcEncryptionControlResourceExclusionsEgressOnlyInternetGateway()
      Describes an exclusion configuration for VPC Encryption Control.

      For more information, see Enforce VPC encryption in transit in the Amazon VPC User Guide.

    • getAttrVpcEncryptionControlResourceExclusionsEgressOnlyInternetGatewayState

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsEgressOnlyInternetGatewayState()
      The current state of the exclusion configuration.
    • getAttrVpcEncryptionControlResourceExclusionsEgressOnlyInternetGatewayStateMessage

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsEgressOnlyInternetGatewayStateMessage()
      A message providing additional information about the exclusion state.
    • getAttrVpcEncryptionControlResourceExclusionsElasticFileSystem

      @Stability(Stable) @NotNull public IResolvable getAttrVpcEncryptionControlResourceExclusionsElasticFileSystem()
      Describes an exclusion configuration for VPC Encryption Control.

      For more information, see Enforce VPC encryption in transit in the Amazon VPC User Guide.

    • getAttrVpcEncryptionControlResourceExclusionsElasticFileSystemState

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsElasticFileSystemState()
      The current state of the exclusion configuration.
    • getAttrVpcEncryptionControlResourceExclusionsElasticFileSystemStateMessage

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsElasticFileSystemStateMessage()
      A message providing additional information about the exclusion state.
    • getAttrVpcEncryptionControlResourceExclusionsInternetGateway

      @Stability(Stable) @NotNull public IResolvable getAttrVpcEncryptionControlResourceExclusionsInternetGateway()
      Describes an exclusion configuration for VPC Encryption Control.

      For more information, see Enforce VPC encryption in transit in the Amazon VPC User Guide.

    • getAttrVpcEncryptionControlResourceExclusionsInternetGatewayState

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsInternetGatewayState()
      The current state of the exclusion configuration.
    • getAttrVpcEncryptionControlResourceExclusionsInternetGatewayStateMessage

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsInternetGatewayStateMessage()
      A message providing additional information about the exclusion state.
    • getAttrVpcEncryptionControlResourceExclusionsLambda

      @Stability(Stable) @NotNull public IResolvable getAttrVpcEncryptionControlResourceExclusionsLambda()
      Describes an exclusion configuration for VPC Encryption Control.

      For more information, see Enforce VPC encryption in transit in the Amazon VPC User Guide.

    • getAttrVpcEncryptionControlResourceExclusionsLambdaState

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsLambdaState()
      The current state of the exclusion configuration.
    • getAttrVpcEncryptionControlResourceExclusionsLambdaStateMessage

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsLambdaStateMessage()
      A message providing additional information about the exclusion state.
    • getAttrVpcEncryptionControlResourceExclusionsNatGateway

      @Stability(Stable) @NotNull public IResolvable getAttrVpcEncryptionControlResourceExclusionsNatGateway()
      Describes an exclusion configuration for VPC Encryption Control.

      For more information, see Enforce VPC encryption in transit in the Amazon VPC User Guide.

    • getAttrVpcEncryptionControlResourceExclusionsNatGatewayState

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsNatGatewayState()
      The current state of the exclusion configuration.
    • getAttrVpcEncryptionControlResourceExclusionsNatGatewayStateMessage

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsNatGatewayStateMessage()
      A message providing additional information about the exclusion state.
    • getAttrVpcEncryptionControlResourceExclusionsVirtualPrivateGateway

      @Stability(Stable) @NotNull public IResolvable getAttrVpcEncryptionControlResourceExclusionsVirtualPrivateGateway()
      Describes an exclusion configuration for VPC Encryption Control.

      For more information, see Enforce VPC encryption in transit in the Amazon VPC User Guide.

    • getAttrVpcEncryptionControlResourceExclusionsVirtualPrivateGatewayState

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsVirtualPrivateGatewayState()
      The current state of the exclusion configuration.
    • getAttrVpcEncryptionControlResourceExclusionsVirtualPrivateGatewayStateMessage

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsVirtualPrivateGatewayStateMessage()
      A message providing additional information about the exclusion state.
    • getAttrVpcEncryptionControlResourceExclusionsVpcLattice

      @Stability(Stable) @NotNull public IResolvable getAttrVpcEncryptionControlResourceExclusionsVpcLattice()
      Describes an exclusion configuration for VPC Encryption Control.

      For more information, see Enforce VPC encryption in transit in the Amazon VPC User Guide.

    • getAttrVpcEncryptionControlResourceExclusionsVpcLatticeState

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsVpcLatticeState()
      The current state of the exclusion configuration.
    • getAttrVpcEncryptionControlResourceExclusionsVpcLatticeStateMessage

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsVpcLatticeStateMessage()
      A message providing additional information about the exclusion state.
    • getAttrVpcEncryptionControlResourceExclusionsVpcPeering

      @Stability(Stable) @NotNull public IResolvable getAttrVpcEncryptionControlResourceExclusionsVpcPeering()
      Describes an exclusion configuration for VPC Encryption Control.

      For more information, see Enforce VPC encryption in transit in the Amazon VPC User Guide.

    • getAttrVpcEncryptionControlResourceExclusionsVpcPeeringState

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsVpcPeeringState()
      The current state of the exclusion configuration.
    • getAttrVpcEncryptionControlResourceExclusionsVpcPeeringStateMessage

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlResourceExclusionsVpcPeeringStateMessage()
      A message providing additional information about the exclusion state.
    • getAttrVpcEncryptionControlState

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlState()
      The current state of the VPC Encryption Control configuration.
    • getAttrVpcEncryptionControlStateMessage

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlStateMessage()
      A message providing additional information about the encryption control state.
    • getAttrVpcEncryptionControlVpcEncryptionControlId

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlVpcEncryptionControlId()
      The ID of the VPC Encryption Control configuration.
    • getAttrVpcEncryptionControlVpcId

      @Stability(Stable) @NotNull public String getAttrVpcEncryptionControlVpcId()
      The ID of the VPC associated with the encryption control configuration.
    • getAttrVpcId

      @Stability(Stable) @NotNull public String getAttrVpcId()
      The ID of the VPC.
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getCfnPropertyNames

      @Stability(Stable) @NotNull protected Map<String,String> getCfnPropertyNames()
      Overrides:
      getCfnPropertyNames in class CfnResource
    • getTags

      @Stability(Stable) @NotNull public TagManager getTags()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getTags in interface ITaggable
    • getVpcRef

      @Stability(Stable) @NotNull public VPCReference getVpcRef()
      A reference to a VPC resource.
      Specified by:
      getVpcRef in interface IVPCRef
    • getCidrBlock

      @Stability(Stable) @Nullable public String getCidrBlock()
      The IPv4 network range for the VPC, in CIDR notation.
    • setCidrBlock

      @Stability(Stable) public void setCidrBlock(@Nullable String value)
      The IPv4 network range for the VPC, in CIDR notation.
    • getEnableDnsHostnames

      @Stability(Stable) @Nullable public Object getEnableDnsHostnames()
      Indicates whether the instances launched in the VPC get DNS hostnames.

      Returns union: either Boolean or IResolvable

    • setEnableDnsHostnames

      @Stability(Stable) public void setEnableDnsHostnames(@Nullable Boolean value)
      Indicates whether the instances launched in the VPC get DNS hostnames.
    • setEnableDnsHostnames

      @Stability(Stable) public void setEnableDnsHostnames(@Nullable IResolvable value)
      Indicates whether the instances launched in the VPC get DNS hostnames.
    • getEnableDnsSupport

      @Stability(Stable) @Nullable public Object getEnableDnsSupport()
      Indicates whether the DNS resolution is supported for the VPC.

      Returns union: either Boolean or IResolvable

    • setEnableDnsSupport

      @Stability(Stable) public void setEnableDnsSupport(@Nullable Boolean value)
      Indicates whether the DNS resolution is supported for the VPC.
    • setEnableDnsSupport

      @Stability(Stable) public void setEnableDnsSupport(@Nullable IResolvable value)
      Indicates whether the DNS resolution is supported for the VPC.
    • getInstanceTenancy

      @Stability(Stable) @Nullable public String getInstanceTenancy()
      The allowed tenancy of instances launched into the VPC.
    • setInstanceTenancy

      @Stability(Stable) public void setInstanceTenancy(@Nullable String value)
      The allowed tenancy of instances launched into the VPC.
    • getIpv4IpamPoolId

      @Stability(Stable) @Nullable public String getIpv4IpamPoolId()
      The ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR.
    • setIpv4IpamPoolId

      @Stability(Stable) public void setIpv4IpamPoolId(@Nullable String value)
      The ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR.
    • getIpv4NetmaskLength

      @Stability(Stable) @Nullable public Number getIpv4NetmaskLength()
      The netmask length of the IPv4 CIDR you want to allocate to this VPC from an Amazon VPC IP Address Manager (IPAM) pool.
    • setIpv4NetmaskLength

      @Stability(Stable) public void setIpv4NetmaskLength(@Nullable Number value)
      The netmask length of the IPv4 CIDR you want to allocate to this VPC from an Amazon VPC IP Address Manager (IPAM) pool.
    • getTagsRaw

      @Stability(Stable) @Nullable public List<CfnTag> getTagsRaw()
      The tags for the VPC.
    • setTagsRaw

      @Stability(Stable) public void setTagsRaw(@Nullable List<CfnTag> value)
      The tags for the VPC.
    • getVpcEncryptionControl

      @Stability(Stable) @Nullable public Object getVpcEncryptionControl()
      Describes the configuration and state of VPC encryption controls.

      Returns union: either IResolvable or CfnVPC.VpcEncryptionControlProperty

    • setVpcEncryptionControl

      @Stability(Stable) public void setVpcEncryptionControl(@Nullable IResolvable value)
      Describes the configuration and state of VPC encryption controls.
    • setVpcEncryptionControl

      @Stability(Stable) public void setVpcEncryptionControl(@Nullable CfnVPC.VpcEncryptionControlProperty value)
      Describes the configuration and state of VPC encryption controls.