Class: AWSCDK::EC2::VPC

Inherits:
Resource
  • Object
show all
Includes:
IVPC
Defined in:
ec2/vpc.rb

Overview

Define an AWS Virtual Private Cloud.

See the package-level documentation of this package for an overview of the various dimensions in which you can configure your VPC.

For example:

vpc = AWSCDK::EC2::VPC.new(self, "TheVPC", {
    ip_addresses: AWSCDK::EC2::IPAddresses.cidr("10.0.0.0/16"),
})

# Iterate the private subnets
selection = vpc.select_subnets({
    subnet_type: AWSCDK::EC2::SubnetType::PRIVATE_WITH_EGRESS,
})

selection[:subnets].each do |subnet|
end

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props = nil) ⇒ VPC

Vpc creates a VPC that spans a whole region.

It will automatically divide the provided VPC CIDR range, and create public and private subnets per Availability Zone. Network routing for the public subnets will be configured to allow outbound access directly via an Internet Gateway. Network routing for the private subnets will be configured to allow outbound access via a set of resilient NAT Gateways (one per AZ).

Parameters:



37
38
39
40
41
42
43
# File 'ec2/vpc.rb', line 37

def initialize(scope, id, props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::EC2::VPCProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlZwY1Byb3BzIn0=")), "props") unless props.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props)
end

Class Method Details

.DEFAULT_CIDR_RANGEString

The default CIDR range used when creating VPCs.

This can be overridden using VpcProps when creating a VPCNetwork resource. e.g. new VpcResource(this, { cidr: '192.168.0.0./16' })

Note this is specific to the IPv4 CIDR.

Returns:

  • (String)


188
189
190
# File 'ec2/vpc.rb', line 188

def self.DEFAULT_CIDR_RANGE()
  Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_ec2.Vpc", "DEFAULT_CIDR_RANGE")
end

.DEFAULT_SUBNETSArray<AWSCDK::EC2::SubnetConfiguration>

The default subnet configuration.

1 Public and 1 Private subnet per AZ evenly split



197
198
199
# File 'ec2/vpc.rb', line 197

def self.DEFAULT_SUBNETS()
  Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_ec2.Vpc", "DEFAULT_SUBNETS")
end

.DEFAULT_SUBNETS_NO_NATArray<AWSCDK::EC2::SubnetConfiguration>

The default subnet configuration if natGateways specified to be 0.

1 Public and 1 Isolated Subnet per AZ evenly split



206
207
208
# File 'ec2/vpc.rb', line 206

def self.DEFAULT_SUBNETS_NO_NAT()
  Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_ec2.Vpc", "DEFAULT_SUBNETS_NO_NAT")
end

.from_lookup(scope, id, options) ⇒ AWSCDK::EC2::IVPC

Import an existing VPC by querying the AWS environment this stack is deployed to.

This function only needs to be used to use VPCs not defined in your CDK application. If you are looking to share a VPC between stacks, you can pass the Vpc object between stacks and use it as normal.

Calling this method will lead to a lookup when the CDK CLI is executed. You can therefore not use any values that will only be available at CloudFormation execution time (i.e., Tokens).

The VPC information will be cached in cdk.context.json and the same VPC will be used on future runs. To refresh the lookup, you will have to evict the value from the cache using the cdk context command. See https://docs.aws.amazon.com/cdk/latest/guide/context.html for more information.

Parameters:

Returns:



106
107
108
109
110
111
112
# File 'ec2/vpc.rb', line 106

def self.from_lookup(scope, id, options)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::VPCLookupOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlZwY0xvb2t1cE9wdGlvbnMifQ==")), "options")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.Vpc", "fromLookup", [scope, id, options])
end

.from_vpc_attributes(scope, id, attrs) ⇒ AWSCDK::EC2::IVPC

Import a VPC by supplying all attributes directly.

NOTE: using from_vpc_attributes() with deploy-time parameters (like a Fn.importValue() or CfnParameter to represent a list of subnet IDs) sometimes accidentally works. It happens to work for constructs that need a list of subnets (like AutoScalingGroup and eks.Cluster) but it does not work for constructs that need individual subnets (like Instance). See https://github.com/aws/aws-cdk/issues/4118 for more information.

Prefer to use Vpc.fromLookup() instead.

Parameters:

Returns:



129
130
131
132
133
134
135
# File 'ec2/vpc.rb', line 129

def self.from_vpc_attributes(scope, id, attrs)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  attrs = attrs.is_a?(Hash) ? ::AWSCDK::EC2::VPCAttributes.new(**attrs.transform_keys(&:to_sym)) : attrs
  Jsii::Type.check_type(attrs, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlZwY0F0dHJpYnV0ZXMifQ==")), "attrs")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ec2.Vpc", "fromVpcAttributes", [scope, id, attrs])
end

.jsii_overridable_methodsObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'ec2/vpc.rb', line 45

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :env => { kind: :property, name: "env", is_optional: false },
    :physical_name => { kind: :property, name: "physicalName", is_optional: false },
    :stack => { kind: :property, name: "stack", is_optional: false },
    :availability_zones => { kind: :property, name: "availabilityZones", is_optional: false },
    :dns_hostnames_enabled => { kind: :property, name: "dnsHostnamesEnabled", is_optional: false },
    :dns_support_enabled => { kind: :property, name: "dnsSupportEnabled", is_optional: false },
    :internet_connectivity_established => { kind: :property, name: "internetConnectivityEstablished", is_optional: false },
    :isolated_subnets => { kind: :property, name: "isolatedSubnets", is_optional: false },
    :private_subnets => { kind: :property, name: "privateSubnets", is_optional: false },
    :public_subnets => { kind: :property, name: "publicSubnets", is_optional: false },
    :vpc_arn => { kind: :property, name: "vpcArn", is_optional: false },
    :vpc_cidr_block => { kind: :property, name: "vpcCidrBlock", is_optional: false },
    :vpc_cidr_block_associations => { kind: :property, name: "vpcCidrBlockAssociations", is_optional: false },
    :vpc_default_network_acl => { kind: :property, name: "vpcDefaultNetworkAcl", is_optional: false },
    :vpc_default_security_group => { kind: :property, name: "vpcDefaultSecurityGroup", is_optional: false },
    :vpc_id => { kind: :property, name: "vpcId", is_optional: false },
    :vpc_ipv6_cidr_blocks => { kind: :property, name: "vpcIpv6CidrBlocks", is_optional: false },
    :vpc_ref => { kind: :property, name: "vpcRef", is_optional: false },
    :internet_gateway_id => { kind: :property, name: "internetGatewayId", is_optional: true },
    :vpn_gateway_id => { kind: :property, name: "vpnGatewayId", is_optional: true },
    :incomplete_subnet_definition => { kind: :property, name: "incompleteSubnetDefinition", is_optional: false },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :apply_cross_stack_reference_strength => { kind: :method, name: "applyCrossStackReferenceStrength", is_optional: false },
    :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false },
    :generate_physical_name => { kind: :method, name: "generatePhysicalName", is_optional: false },
    :get_resource_arn_attribute => { kind: :method, name: "getResourceArnAttribute", is_optional: false },
    :get_resource_name_attribute => { kind: :method, name: "getResourceNameAttribute", is_optional: false },
    :add_client_vpn_endpoint => { kind: :method, name: "addClientVpnEndpoint", is_optional: false },
    :add_flow_log => { kind: :method, name: "addFlowLog", is_optional: false },
    :add_gateway_endpoint => { kind: :method, name: "addGatewayEndpoint", is_optional: false },
    :add_interface_endpoint => { kind: :method, name: "addInterfaceEndpoint", is_optional: false },
    :add_vpn_connection => { kind: :method, name: "addVpnConnection", is_optional: false },
    :enable_vpn_gateway => { kind: :method, name: "enableVpnGateway", is_optional: false },
    :select_subnet_objects => { kind: :method, name: "selectSubnetObjects", is_optional: false },
    :select_subnets => { kind: :method, name: "selectSubnets", is_optional: false },
  }
end

.PROPERTY_INJECTION_IDString

Uniquely identifies this class.

Returns:

  • (String)


213
214
215
# File 'ec2/vpc.rb', line 213

def self.PROPERTY_INJECTION_ID()
  Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_ec2.Vpc", "PROPERTY_INJECTION_ID")
end

Instance Method Details

#add_client_vpn_endpoint(id, options) ⇒ AWSCDK::EC2::ClientVpnEndpoint

Adds a new client VPN endpoint to this VPC.

Parameters:

Returns:



438
439
440
441
442
443
# File 'ec2/vpc.rb', line 438

def add_client_vpn_endpoint(id, options)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::ClientVpnEndpointOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkNsaWVudFZwbkVuZHBvaW50T3B0aW9ucyJ9")), "options")
  jsii_call_method("addClientVpnEndpoint", [id, options])
end

#add_flow_log(id, options = nil) ⇒ AWSCDK::EC2::FlowLog

Adds a new flow log to this VPC.

Parameters:

Returns:



450
451
452
453
454
455
# File 'ec2/vpc.rb', line 450

def add_flow_log(id, options = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::FlowLogOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkZsb3dMb2dPcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("addFlowLog", [id, options])
end

#add_gateway_endpoint(id, options) ⇒ AWSCDK::EC2::GatewayVPCEndpoint

Adds a new gateway endpoint to this VPC.

Parameters:

Returns:



462
463
464
465
466
467
# File 'ec2/vpc.rb', line 462

def add_gateway_endpoint(id, options)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::GatewayVPCEndpointOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkdhdGV3YXlWcGNFbmRwb2ludE9wdGlvbnMifQ==")), "options")
  jsii_call_method("addGatewayEndpoint", [id, options])
end

#add_interface_endpoint(id, options) ⇒ AWSCDK::EC2::InterfaceVPCEndpoint

Adds a new interface endpoint to this VPC.



474
475
476
477
478
479
# File 'ec2/vpc.rb', line 474

def add_interface_endpoint(id, options)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::InterfaceVPCEndpointOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkludGVyZmFjZVZwY0VuZHBvaW50T3B0aW9ucyJ9")), "options")
  jsii_call_method("addInterfaceEndpoint", [id, options])
end

#add_vpn_connection(id, options) ⇒ AWSCDK::EC2::VpnConnection

Adds a new VPN connection to this VPC.

Parameters:

Returns:



486
487
488
489
490
491
# File 'ec2/vpc.rb', line 486

def add_vpn_connection(id, options)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::VpnConnectionOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlZwbkNvbm5lY3Rpb25PcHRpb25zIn0=")), "options")
  jsii_call_method("addVpnConnection", [id, options])
end

#apply_cross_stack_reference_strength(strength) ⇒ void

This method returns an undefined value.

Override the cross-stack reference strength for this resource.

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters:



376
377
378
379
# File 'ec2/vpc.rb', line 376

def apply_cross_stack_reference_strength(strength)
  Jsii::Type.check_type(strength, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZWZlcmVuY2VTdHJlbmd0aCJ9")), "strength")
  jsii_call_method("applyCrossStackReferenceStrength", [strength])
end

#apply_removal_policy(policy) ⇒ void

This method returns an undefined value.

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:



393
394
395
396
# File 'ec2/vpc.rb', line 393

def apply_removal_policy(policy)
  Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy")
  jsii_call_method("applyRemovalPolicy", [policy])
end

#availability_zonesArray<String>

AZs for this VPC.

Returns:

  • (Array<String>)


220
221
222
# File 'ec2/vpc.rb', line 220

def availability_zones()
  jsii_get_property("availabilityZones")
end

#dns_hostnames_enabledBoolean

Indicates if instances launched in this VPC will have public DNS hostnames.

Returns:

  • (Boolean)


227
228
229
# File 'ec2/vpc.rb', line 227

def dns_hostnames_enabled()
  jsii_get_property("dnsHostnamesEnabled")
end

#dns_support_enabledBoolean

Indicates if DNS support is enabled for this VPC.

Returns:

  • (Boolean)


234
235
236
# File 'ec2/vpc.rb', line 234

def dns_support_enabled()
  jsii_get_property("dnsSupportEnabled")
end

#enable_vpn_gateway(options) ⇒ void

This method returns an undefined value.

Adds a VPN Gateway to this VPC.

Parameters:



497
498
499
500
501
# File 'ec2/vpc.rb', line 497

def enable_vpn_gateway(options)
  options = options.is_a?(Hash) ? ::AWSCDK::EC2::EnableVpnGatewayOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkVuYWJsZVZwbkdhdGV3YXlPcHRpb25zIn0=")), "options")
  jsii_call_method("enableVpnGateway", [options])
end

#envAWSCDK::Interfaces::ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.



155
156
157
# File 'ec2/vpc.rb', line 155

def env()
  jsii_get_property("env")
end

#generate_physical_nameString

Returns:

  • (String)


399
400
401
# File 'ec2/vpc.rb', line 399

def generate_physical_name()
  jsii_call_method("generatePhysicalName", [])
end

#get_resource_arn_attribute(arn_attr, arn_components) ⇒ String

Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. bucket.bucketArn).

Normally, this token will resolve to arn_attr, but if the resource is referenced across environments, arn_components will be used to synthesize a concrete ARN with the resource's physical name. Make sure to reference this.physicalName in arn_components.

Parameters:

  • arn_attr (String)

    The CFN attribute which resolves to the ARN of the resource.

  • arn_components (AWSCDK::ARNComponents)

    The format of the ARN of this resource.

Returns:

  • (String)


413
414
415
416
417
418
# File 'ec2/vpc.rb', line 413

def get_resource_arn_attribute(arn_attr, arn_components)
  Jsii::Type.check_type(arn_attr, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "arnAttr")
  arn_components = arn_components.is_a?(Hash) ? ::AWSCDK::ARNComponents.new(**arn_components.transform_keys(&:to_sym)) : arn_components
  Jsii::Type.check_type(arn_components, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Bcm5Db21wb25lbnRzIn0=")), "arnComponents")
  jsii_call_method("getResourceArnAttribute", [arn_attr, arn_components])
end

#get_resource_name_attribute(name_attr) ⇒ String

Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. bucket.bucketName).

Normally, this token will resolve to name_attr, but if the resource is referenced across environments, it will be resolved to this.physicalName, which will be a concrete name.

Parameters:

  • name_attr (String)

    The CFN attribute which resolves to the resource's name.

Returns:

  • (String)


428
429
430
431
# File 'ec2/vpc.rb', line 428

def get_resource_name_attribute(name_attr)
  Jsii::Type.check_type(name_attr, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "nameAttr")
  jsii_call_method("getResourceNameAttribute", [name_attr])
end

#incomplete_subnet_definitionBoolean

If this is set to true, don't error out on trying to select subnets.

Returns:

  • (Boolean)


334
335
336
# File 'ec2/vpc.rb', line 334

def incomplete_subnet_definition()
  jsii_get_property("incompleteSubnetDefinition")
end

#incomplete_subnet_definition=(value) ⇒ Object



338
339
340
341
# File 'ec2/vpc.rb', line 338

def incomplete_subnet_definition=(value)
  Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "incompleteSubnetDefinition")
  jsii_set_property("incompleteSubnetDefinition", value)
end

#internet_connectivity_establishedConstructs::IDependable

Dependencies for internet connectivity.

Returns:

  • (Constructs::IDependable)


241
242
243
# File 'ec2/vpc.rb', line 241

def internet_connectivity_established()
  jsii_get_property("internetConnectivityEstablished")
end

#internet_gateway_idString?

Internet Gateway for the VPC.

Note that in case the VPC is configured only with ISOLATED subnets, this attribute will be undefined.

Returns:

  • (String, nil)


320
321
322
# File 'ec2/vpc.rb', line 320

def internet_gateway_id()
  jsii_get_property("internetGatewayId")
end

#isolated_subnetsArray<AWSCDK::EC2::ISubnet>

List of isolated subnets in this VPC.

Returns:



248
249
250
# File 'ec2/vpc.rb', line 248

def isolated_subnets()
  jsii_get_property("isolatedSubnets")
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


140
141
142
# File 'ec2/vpc.rb', line 140

def node()
  jsii_get_property("node")
end

#physical_nameString

Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.

This value will resolve to one of the following:

  • a concrete value (e.g. "my-awesome-bucket")
  • undefined, when a name should be generated by CloudFormation
  • a concrete name generated automatically during synthesis, in cross-environment scenarios.

Returns:

  • (String)


169
170
171
# File 'ec2/vpc.rb', line 169

def physical_name()
  jsii_get_property("physicalName")
end

#private_subnetsArray<AWSCDK::EC2::ISubnet>

List of private subnets in this VPC.

Returns:



255
256
257
# File 'ec2/vpc.rb', line 255

def private_subnets()
  jsii_get_property("privateSubnets")
end

#public_subnetsArray<AWSCDK::EC2::ISubnet>

List of public subnets in this VPC.

Returns:



262
263
264
# File 'ec2/vpc.rb', line 262

def public_subnets()
  jsii_get_property("publicSubnets")
end

#select_subnet_objects(selection = nil) ⇒ Array<AWSCDK::EC2::ISubnet>

Return the subnets appropriate for the placement strategy.

Parameters:

Returns:



507
508
509
510
511
# File 'ec2/vpc.rb', line 507

def select_subnet_objects(selection = nil)
  selection = selection.is_a?(Hash) ? ::AWSCDK::EC2::SubnetSelection.new(**selection.transform_keys(&:to_sym)) : selection
  Jsii::Type.check_type(selection, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlN1Ym5ldFNlbGVjdGlvbiJ9")), "selection") unless selection.nil?
  jsii_call_method("selectSubnetObjects", [selection])
end

#select_subnets(selection = nil) ⇒ AWSCDK::EC2::SelectedSubnets

Returns IDs of selected subnets.

Parameters:

Returns:



517
518
519
520
521
# File 'ec2/vpc.rb', line 517

def select_subnets(selection = nil)
  selection = selection.is_a?(Hash) ? ::AWSCDK::EC2::SubnetSelection.new(**selection.transform_keys(&:to_sym)) : selection
  Jsii::Type.check_type(selection, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlN1Ym5ldFNlbGVjdGlvbiJ9")), "selection") unless selection.nil?
  jsii_call_method("selectSubnets", [selection])
end

#stackAWSCDK::Stack

The stack in which this resource is defined.

Returns:



176
177
178
# File 'ec2/vpc.rb', line 176

def stack()
  jsii_get_property("stack")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


346
347
348
# File 'ec2/vpc.rb', line 346

def to_string()
  jsii_call_method("toString", [])
end

#vpc_arnString

Arn of this VPC.

Returns:

  • (String)


269
270
271
# File 'ec2/vpc.rb', line 269

def vpc_arn()
  jsii_get_property("vpcArn")
end

#vpc_cidr_blockString

CIDR range for this VPC.

Returns:

  • (String)


276
277
278
# File 'ec2/vpc.rb', line 276

def vpc_cidr_block()
  jsii_get_property("vpcCidrBlock")
end

#vpc_cidr_block_associationsArray<String>

Returns:

  • (Array<String>)


281
282
283
# File 'ec2/vpc.rb', line 281

def vpc_cidr_block_associations()
  jsii_get_property("vpcCidrBlockAssociations")
end

#vpc_default_network_aclString

Returns:

  • (String)


286
287
288
# File 'ec2/vpc.rb', line 286

def vpc_default_network_acl()
  jsii_get_property("vpcDefaultNetworkAcl")
end

#vpc_default_security_groupString

Returns:

  • (String)


291
292
293
# File 'ec2/vpc.rb', line 291

def vpc_default_security_group()
  jsii_get_property("vpcDefaultSecurityGroup")
end

#vpc_idString

Identifier for this VPC.

Returns:

  • (String)


298
299
300
# File 'ec2/vpc.rb', line 298

def vpc_id()
  jsii_get_property("vpcId")
end

#vpc_ipv6_cidr_blocksArray<String>

Returns:

  • (Array<String>)


303
304
305
# File 'ec2/vpc.rb', line 303

def vpc_ipv6_cidr_blocks()
  jsii_get_property("vpcIpv6CidrBlocks")
end

#vpc_refAWSCDK::Interfaces::AWSEC2::VPCReference

A reference to a VPC resource.



310
311
312
# File 'ec2/vpc.rb', line 310

def vpc_ref()
  jsii_get_property("vpcRef")
end

#vpn_gateway_idString?

Returns the id of the VPN Gateway (if enabled).

Returns:

  • (String, nil)


327
328
329
# File 'ec2/vpc.rb', line 327

def vpn_gateway_id()
  jsii_get_property("vpnGatewayId")
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

Parameters:

  • mixins (Array<Constructs::IMixin>)

Returns:

  • (Constructs::IConstruct)


359
360
361
362
363
364
# File 'ec2/vpc.rb', line 359

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end