aws-cdk.aws-ec2-alpha 2.169.0a0__py3-none-any.whl → 2.171.0a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of aws-cdk.aws-ec2-alpha might be problematic. Click here for more details.
- aws_cdk/aws_ec2_alpha/__init__.py +691 -18
- aws_cdk/aws_ec2_alpha/_jsii/__init__.py +2 -2
- aws_cdk/aws_ec2_alpha/_jsii/aws-ec2-alpha@2.171.0-alpha.0.jsii.tgz +0 -0
- {aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info → aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info}/METADATA +151 -2
- aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info/RECORD +10 -0
- {aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info → aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info}/WHEEL +1 -1
- aws_cdk/aws_ec2_alpha/_jsii/aws-ec2-alpha@2.169.0-alpha.0.jsii.tgz +0 -0
- aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info/RECORD +0 -10
- {aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info → aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info}/LICENSE +0 -0
- {aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info → aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info}/NOTICE +0 -0
- {aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info → aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info}/top_level.txt +0 -0
|
@@ -221,6 +221,155 @@ Route(self, "DynamoDBRoute",
|
|
|
221
221
|
)
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
+
## VPC Peering Connection
|
|
225
|
+
|
|
226
|
+
VPC peering connection allows you to connect two VPCs and route traffic between them using private IP addresses. The VpcV2 construct supports creating VPC peering connections through the `VPCPeeringConnection` construct from the `route` module.
|
|
227
|
+
|
|
228
|
+
Peering Connection cannot be established between two VPCs with overlapping CIDR ranges. Please make sure the two VPC CIDRs do not overlap with each other else it will throw an error.
|
|
229
|
+
|
|
230
|
+
For more information, see [What is VPC peering?](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html).
|
|
231
|
+
|
|
232
|
+
The following show examples of how to create a peering connection between two VPCs for all possible combinations of same-account or cross-account, and same-region or cross-region configurations.
|
|
233
|
+
|
|
234
|
+
Note: You cannot create a VPC peering connection between VPCs that have matching or overlapping CIDR blocks
|
|
235
|
+
|
|
236
|
+
**Case 1: Same Account and Same Region Peering Connection**
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
stack = Stack()
|
|
240
|
+
|
|
241
|
+
vpc_a = VpcV2(self, "VpcA",
|
|
242
|
+
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
vpc_b = VpcV2(self, "VpcB",
|
|
246
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
peering_connection = vpc_a.create_peering_connection("sameAccountSameRegionPeering",
|
|
250
|
+
acceptor_vpc=vpc_b
|
|
251
|
+
)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Case 2: Same Account and Cross Region Peering Connection**
|
|
255
|
+
|
|
256
|
+
There is no difference from Case 1 when calling `createPeeringConnection`. The only change is that one of the VPCs are created in another stack with a different region. To establish cross region VPC peering connection, acceptorVpc needs to be imported to the requestor VPC stack using `fromVpcV2Attributes` method.
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
app = App()
|
|
260
|
+
|
|
261
|
+
stack_a = Stack(app, "VpcStackA", env=Environment(account="000000000000", region="us-east-1"))
|
|
262
|
+
stack_b = Stack(app, "VpcStackB", env=Environment(account="000000000000", region="us-west-2"))
|
|
263
|
+
|
|
264
|
+
vpc_a = VpcV2(stack_a, "VpcA",
|
|
265
|
+
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
VpcV2(stack_b, "VpcB",
|
|
269
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
vpc_b = VpcV2.from_vpc_v2_attributes(stack_a, "ImportedVpcB",
|
|
273
|
+
vpc_id="MockVpcBid",
|
|
274
|
+
vpc_cidr_block="10.1.0.0/16",
|
|
275
|
+
region="us-west-2",
|
|
276
|
+
owner_account_id="000000000000"
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
peering_connection = vpc_a.create_peering_connection("sameAccountCrossRegionPeering",
|
|
280
|
+
acceptor_vpc=vpc_b
|
|
281
|
+
)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Case 3: Cross Account Peering Connection**
|
|
285
|
+
|
|
286
|
+
For cross-account connections, the acceptor account needs an IAM role that grants the requestor account permission to initiate the connection. Create a new IAM role in the acceptor account using method `createAcceptorVpcRole` to provide the necessary permissions.
|
|
287
|
+
|
|
288
|
+
Once role is created in account, provide role arn for field `peerRoleArn` under method `createPeeringConnection`
|
|
289
|
+
|
|
290
|
+
```python
|
|
291
|
+
stack = Stack()
|
|
292
|
+
|
|
293
|
+
acceptor_vpc = VpcV2(self, "VpcA",
|
|
294
|
+
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
acceptor_role_arn = acceptor_vpc.create_acceptor_vpc_role("000000000000")
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
After creating an IAM role in the acceptor account, we can initiate the peering connection request from the requestor VPC. Import accpeptorVpc to the stack using `fromVpcV2Attributes` method, it is recommended to specify owner account id of the acceptor VPC in case of cross account peering connection, if acceptor VPC is hosted in different region provide region value for import as well.
|
|
301
|
+
The following code snippet demonstrates how to set up VPC peering between two VPCs in different AWS accounts using CDK:
|
|
302
|
+
|
|
303
|
+
```python
|
|
304
|
+
stack = Stack()
|
|
305
|
+
|
|
306
|
+
acceptor_vpc = VpcV2.from_vpc_v2_attributes(self, "acceptorVpc",
|
|
307
|
+
vpc_id="vpc-XXXX",
|
|
308
|
+
vpc_cidr_block="10.0.0.0/16",
|
|
309
|
+
region="us-east-2",
|
|
310
|
+
owner_account_id="111111111111"
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
acceptor_role_arn = "arn:aws:iam::111111111111:role/VpcPeeringRole"
|
|
314
|
+
|
|
315
|
+
requestor_vpc = VpcV2(self, "VpcB",
|
|
316
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
peering_connection = requestor_vpc.create_peering_connection("crossAccountCrossRegionPeering",
|
|
320
|
+
acceptor_vpc=acceptor_vpc,
|
|
321
|
+
peer_role_arn=acceptor_role_arn
|
|
322
|
+
)
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Route Table Configuration
|
|
326
|
+
|
|
327
|
+
After establishing the VPC peering connection, routes must be added to the respective route tables in the VPCs to enable traffic flow. If a route is added to the requestor stack, information will be able to flow from the requestor VPC to the acceptor VPC, but not in the reverse direction. For bi-directional communication, routes need to be added in both VPCs from their respective stacks.
|
|
328
|
+
|
|
329
|
+
For more information, see [Update your route tables for a VPC peering connection](https://docs.aws.amazon.com/vpc/latest/peering/vpc-peering-routing.html).
|
|
330
|
+
|
|
331
|
+
```python
|
|
332
|
+
stack = Stack()
|
|
333
|
+
|
|
334
|
+
acceptor_vpc = VpcV2(self, "VpcA",
|
|
335
|
+
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
requestor_vpc = VpcV2(self, "VpcB",
|
|
339
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
peering_connection = requestor_vpc.create_peering_connection("peeringConnection",
|
|
343
|
+
acceptor_vpc=acceptor_vpc
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
route_table = RouteTable(self, "RouteTable",
|
|
347
|
+
vpc=requestor_vpc
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
route_table.add_route("vpcPeeringRoute", "10.0.0.0/16", {"gateway": peering_connection})
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
This can also be done using AWS CLI. For more information, see [create-route](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-route.html).
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
# Add a route to the requestor VPC route table
|
|
357
|
+
aws ec2 create-route --route-table-id rtb-requestor --destination-cidr-block 10.0.0.0/16 --vpc-peering-connection-id pcx-xxxxxxxx
|
|
358
|
+
|
|
359
|
+
# For bi-directional add a route in the acceptor vpc account as well
|
|
360
|
+
aws ec2 create-route --route-table-id rtb-acceptor --destination-cidr-block 10.1.0.0/16 --vpc-peering-connection-id pcx-xxxxxxxx
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### Deleting the Peering Connection
|
|
364
|
+
|
|
365
|
+
To delete a VPC peering connection, use the following command:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
aws ec2 delete-vpc-peering-connection --vpc-peering-connection-id pcx-xxxxxxxx
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
For more information, see [Delete a VPC peering connection](https://docs.aws.amazon.com/vpc/latest/peering/create-vpc-peering-connection.html#delete-vpc-peering-connection).
|
|
372
|
+
|
|
224
373
|
## Adding Egress-Only Internet Gateway to VPC
|
|
225
374
|
|
|
226
375
|
An egress-only internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows outbound communication over IPv6 from instances in your VPC to the internet, and prevents the internet from initiating an IPv6 connection with your instances.
|
|
@@ -511,6 +660,7 @@ from ._jsii import *
|
|
|
511
660
|
|
|
512
661
|
import aws_cdk as _aws_cdk_ceddda9d
|
|
513
662
|
import aws_cdk.aws_ec2 as _aws_cdk_aws_ec2_ceddda9d
|
|
663
|
+
import aws_cdk.aws_iam as _aws_cdk_aws_iam_ceddda9d
|
|
514
664
|
import aws_cdk.aws_logs as _aws_cdk_aws_logs_ceddda9d
|
|
515
665
|
import constructs as _constructs_77d1e7e8
|
|
516
666
|
|
|
@@ -1492,6 +1642,43 @@ class IVpcV2(_aws_cdk_aws_ec2_ceddda9d.IVpc, typing_extensions.Protocol):
|
|
|
1492
1642
|
'''
|
|
1493
1643
|
...
|
|
1494
1644
|
|
|
1645
|
+
@jsii.member(jsii_name="createAcceptorVpcRole")
|
|
1646
|
+
def create_acceptor_vpc_role(
|
|
1647
|
+
self,
|
|
1648
|
+
requestor_account_id: builtins.str,
|
|
1649
|
+
) -> _aws_cdk_aws_iam_ceddda9d.Role:
|
|
1650
|
+
'''(experimental) Adds a new role to acceptor VPC account A cross account role is required for the VPC to peer with another account.
|
|
1651
|
+
|
|
1652
|
+
For more information, see the {@link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/peer-with-vpc-in-another-account.html}.
|
|
1653
|
+
|
|
1654
|
+
:param requestor_account_id: -
|
|
1655
|
+
|
|
1656
|
+
:stability: experimental
|
|
1657
|
+
'''
|
|
1658
|
+
...
|
|
1659
|
+
|
|
1660
|
+
@jsii.member(jsii_name="createPeeringConnection")
|
|
1661
|
+
def create_peering_connection(
|
|
1662
|
+
self,
|
|
1663
|
+
id: builtins.str,
|
|
1664
|
+
*,
|
|
1665
|
+
acceptor_vpc: "IVpcV2",
|
|
1666
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
1667
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
1668
|
+
) -> "VPCPeeringConnection":
|
|
1669
|
+
'''(experimental) Creates a new peering connection A peering connection is a private virtual network established between two VPCs.
|
|
1670
|
+
|
|
1671
|
+
For more information, see the {@link https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html}.
|
|
1672
|
+
|
|
1673
|
+
:param id: -
|
|
1674
|
+
:param acceptor_vpc: (experimental) The VPC that is accepting the peering connection.
|
|
1675
|
+
:param peer_role_arn: (experimental) The role arn created in the acceptor account. Default: - no peerRoleArn needed if not cross account connection
|
|
1676
|
+
:param vpc_peering_connection_name: (experimental) The resource name of the peering connection. Default: - peering connection provisioned without any name
|
|
1677
|
+
|
|
1678
|
+
:stability: experimental
|
|
1679
|
+
'''
|
|
1680
|
+
...
|
|
1681
|
+
|
|
1495
1682
|
@jsii.member(jsii_name="enableVpnGatewayV2")
|
|
1496
1683
|
def enable_vpn_gateway_v2(
|
|
1497
1684
|
self,
|
|
@@ -1676,6 +1863,55 @@ class _IVpcV2Proxy(
|
|
|
1676
1863
|
|
|
1677
1864
|
return typing.cast("NatGateway", jsii.invoke(self, "addNatGateway", [options]))
|
|
1678
1865
|
|
|
1866
|
+
@jsii.member(jsii_name="createAcceptorVpcRole")
|
|
1867
|
+
def create_acceptor_vpc_role(
|
|
1868
|
+
self,
|
|
1869
|
+
requestor_account_id: builtins.str,
|
|
1870
|
+
) -> _aws_cdk_aws_iam_ceddda9d.Role:
|
|
1871
|
+
'''(experimental) Adds a new role to acceptor VPC account A cross account role is required for the VPC to peer with another account.
|
|
1872
|
+
|
|
1873
|
+
For more information, see the {@link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/peer-with-vpc-in-another-account.html}.
|
|
1874
|
+
|
|
1875
|
+
:param requestor_account_id: -
|
|
1876
|
+
|
|
1877
|
+
:stability: experimental
|
|
1878
|
+
'''
|
|
1879
|
+
if __debug__:
|
|
1880
|
+
type_hints = typing.get_type_hints(_typecheckingstub__cb54cb9dd15b7bc3477efe1017142f91e359c4d2220c0bd556b2b114780a28d4)
|
|
1881
|
+
check_type(argname="argument requestor_account_id", value=requestor_account_id, expected_type=type_hints["requestor_account_id"])
|
|
1882
|
+
return typing.cast(_aws_cdk_aws_iam_ceddda9d.Role, jsii.invoke(self, "createAcceptorVpcRole", [requestor_account_id]))
|
|
1883
|
+
|
|
1884
|
+
@jsii.member(jsii_name="createPeeringConnection")
|
|
1885
|
+
def create_peering_connection(
|
|
1886
|
+
self,
|
|
1887
|
+
id: builtins.str,
|
|
1888
|
+
*,
|
|
1889
|
+
acceptor_vpc: IVpcV2,
|
|
1890
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
1891
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
1892
|
+
) -> "VPCPeeringConnection":
|
|
1893
|
+
'''(experimental) Creates a new peering connection A peering connection is a private virtual network established between two VPCs.
|
|
1894
|
+
|
|
1895
|
+
For more information, see the {@link https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html}.
|
|
1896
|
+
|
|
1897
|
+
:param id: -
|
|
1898
|
+
:param acceptor_vpc: (experimental) The VPC that is accepting the peering connection.
|
|
1899
|
+
:param peer_role_arn: (experimental) The role arn created in the acceptor account. Default: - no peerRoleArn needed if not cross account connection
|
|
1900
|
+
:param vpc_peering_connection_name: (experimental) The resource name of the peering connection. Default: - peering connection provisioned without any name
|
|
1901
|
+
|
|
1902
|
+
:stability: experimental
|
|
1903
|
+
'''
|
|
1904
|
+
if __debug__:
|
|
1905
|
+
type_hints = typing.get_type_hints(_typecheckingstub__4919a255fea8cc4db70fd26400dd951f53e86d9e4e3aa3b925f0e5fc7b14d4b5)
|
|
1906
|
+
check_type(argname="argument id", value=id, expected_type=type_hints["id"])
|
|
1907
|
+
options = VPCPeeringConnectionOptions(
|
|
1908
|
+
acceptor_vpc=acceptor_vpc,
|
|
1909
|
+
peer_role_arn=peer_role_arn,
|
|
1910
|
+
vpc_peering_connection_name=vpc_peering_connection_name,
|
|
1911
|
+
)
|
|
1912
|
+
|
|
1913
|
+
return typing.cast("VPCPeeringConnection", jsii.invoke(self, "createPeeringConnection", [id, options]))
|
|
1914
|
+
|
|
1679
1915
|
@jsii.member(jsii_name="enableVpnGatewayV2")
|
|
1680
1916
|
def enable_vpn_gateway_v2(
|
|
1681
1917
|
self,
|
|
@@ -4994,6 +5230,322 @@ class VPCCidrBlockattributes:
|
|
|
4994
5230
|
)
|
|
4995
5231
|
|
|
4996
5232
|
|
|
5233
|
+
@jsii.implements(IRouteTarget)
|
|
5234
|
+
class VPCPeeringConnection(
|
|
5235
|
+
_aws_cdk_ceddda9d.Resource,
|
|
5236
|
+
metaclass=jsii.JSIIMeta,
|
|
5237
|
+
jsii_type="@aws-cdk/aws-ec2-alpha.VPCPeeringConnection",
|
|
5238
|
+
):
|
|
5239
|
+
'''(experimental) Creates a peering connection between two VPCs.
|
|
5240
|
+
|
|
5241
|
+
:stability: experimental
|
|
5242
|
+
:resource: AWS::EC2::VPCPeeringConnection
|
|
5243
|
+
:exampleMetadata: infused
|
|
5244
|
+
|
|
5245
|
+
Example::
|
|
5246
|
+
|
|
5247
|
+
stack = Stack()
|
|
5248
|
+
|
|
5249
|
+
acceptor_vpc = VpcV2(self, "VpcA",
|
|
5250
|
+
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
|
|
5251
|
+
)
|
|
5252
|
+
|
|
5253
|
+
requestor_vpc = VpcV2(self, "VpcB",
|
|
5254
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
5255
|
+
)
|
|
5256
|
+
|
|
5257
|
+
peering_connection = requestor_vpc.create_peering_connection("peeringConnection",
|
|
5258
|
+
acceptor_vpc=acceptor_vpc
|
|
5259
|
+
)
|
|
5260
|
+
|
|
5261
|
+
route_table = RouteTable(self, "RouteTable",
|
|
5262
|
+
vpc=requestor_vpc
|
|
5263
|
+
)
|
|
5264
|
+
|
|
5265
|
+
route_table.add_route("vpcPeeringRoute", "10.0.0.0/16", {"gateway": peering_connection})
|
|
5266
|
+
'''
|
|
5267
|
+
|
|
5268
|
+
def __init__(
|
|
5269
|
+
self,
|
|
5270
|
+
scope: _constructs_77d1e7e8.Construct,
|
|
5271
|
+
id: builtins.str,
|
|
5272
|
+
*,
|
|
5273
|
+
requestor_vpc: IVpcV2,
|
|
5274
|
+
acceptor_vpc: IVpcV2,
|
|
5275
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
5276
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
5277
|
+
) -> None:
|
|
5278
|
+
'''
|
|
5279
|
+
:param scope: -
|
|
5280
|
+
:param id: -
|
|
5281
|
+
:param requestor_vpc: (experimental) The VPC that is requesting the peering connection.
|
|
5282
|
+
:param acceptor_vpc: (experimental) The VPC that is accepting the peering connection.
|
|
5283
|
+
:param peer_role_arn: (experimental) The role arn created in the acceptor account. Default: - no peerRoleArn needed if not cross account connection
|
|
5284
|
+
:param vpc_peering_connection_name: (experimental) The resource name of the peering connection. Default: - peering connection provisioned without any name
|
|
5285
|
+
|
|
5286
|
+
:stability: experimental
|
|
5287
|
+
'''
|
|
5288
|
+
if __debug__:
|
|
5289
|
+
type_hints = typing.get_type_hints(_typecheckingstub__adba7b6a63c8eb67b053fce652ae79528cbaae45a3febbc3dde851a8a9afa655)
|
|
5290
|
+
check_type(argname="argument scope", value=scope, expected_type=type_hints["scope"])
|
|
5291
|
+
check_type(argname="argument id", value=id, expected_type=type_hints["id"])
|
|
5292
|
+
props = VPCPeeringConnectionProps(
|
|
5293
|
+
requestor_vpc=requestor_vpc,
|
|
5294
|
+
acceptor_vpc=acceptor_vpc,
|
|
5295
|
+
peer_role_arn=peer_role_arn,
|
|
5296
|
+
vpc_peering_connection_name=vpc_peering_connection_name,
|
|
5297
|
+
)
|
|
5298
|
+
|
|
5299
|
+
jsii.create(self.__class__, self, [scope, id, props])
|
|
5300
|
+
|
|
5301
|
+
@builtins.property
|
|
5302
|
+
@jsii.member(jsii_name="resource")
|
|
5303
|
+
def resource(self) -> _aws_cdk_aws_ec2_ceddda9d.CfnVPCPeeringConnection:
|
|
5304
|
+
'''(experimental) The VPC peering connection CFN resource.
|
|
5305
|
+
|
|
5306
|
+
:stability: experimental
|
|
5307
|
+
'''
|
|
5308
|
+
return typing.cast(_aws_cdk_aws_ec2_ceddda9d.CfnVPCPeeringConnection, jsii.get(self, "resource"))
|
|
5309
|
+
|
|
5310
|
+
@builtins.property
|
|
5311
|
+
@jsii.member(jsii_name="routerTargetId")
|
|
5312
|
+
def router_target_id(self) -> builtins.str:
|
|
5313
|
+
'''(experimental) The ID of the route target.
|
|
5314
|
+
|
|
5315
|
+
:stability: experimental
|
|
5316
|
+
'''
|
|
5317
|
+
return typing.cast(builtins.str, jsii.get(self, "routerTargetId"))
|
|
5318
|
+
|
|
5319
|
+
@builtins.property
|
|
5320
|
+
@jsii.member(jsii_name="routerType")
|
|
5321
|
+
def router_type(self) -> _aws_cdk_aws_ec2_ceddda9d.RouterType:
|
|
5322
|
+
'''(experimental) The type of router used in the route.
|
|
5323
|
+
|
|
5324
|
+
:stability: experimental
|
|
5325
|
+
'''
|
|
5326
|
+
return typing.cast(_aws_cdk_aws_ec2_ceddda9d.RouterType, jsii.get(self, "routerType"))
|
|
5327
|
+
|
|
5328
|
+
|
|
5329
|
+
@jsii.data_type(
|
|
5330
|
+
jsii_type="@aws-cdk/aws-ec2-alpha.VPCPeeringConnectionOptions",
|
|
5331
|
+
jsii_struct_bases=[],
|
|
5332
|
+
name_mapping={
|
|
5333
|
+
"acceptor_vpc": "acceptorVpc",
|
|
5334
|
+
"peer_role_arn": "peerRoleArn",
|
|
5335
|
+
"vpc_peering_connection_name": "vpcPeeringConnectionName",
|
|
5336
|
+
},
|
|
5337
|
+
)
|
|
5338
|
+
class VPCPeeringConnectionOptions:
|
|
5339
|
+
def __init__(
|
|
5340
|
+
self,
|
|
5341
|
+
*,
|
|
5342
|
+
acceptor_vpc: IVpcV2,
|
|
5343
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
5344
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
5345
|
+
) -> None:
|
|
5346
|
+
'''(experimental) Options to define a VPC peering connection.
|
|
5347
|
+
|
|
5348
|
+
:param acceptor_vpc: (experimental) The VPC that is accepting the peering connection.
|
|
5349
|
+
:param peer_role_arn: (experimental) The role arn created in the acceptor account. Default: - no peerRoleArn needed if not cross account connection
|
|
5350
|
+
:param vpc_peering_connection_name: (experimental) The resource name of the peering connection. Default: - peering connection provisioned without any name
|
|
5351
|
+
|
|
5352
|
+
:stability: experimental
|
|
5353
|
+
:exampleMetadata: infused
|
|
5354
|
+
|
|
5355
|
+
Example::
|
|
5356
|
+
|
|
5357
|
+
stack = Stack()
|
|
5358
|
+
|
|
5359
|
+
acceptor_vpc = VpcV2(self, "VpcA",
|
|
5360
|
+
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
|
|
5361
|
+
)
|
|
5362
|
+
|
|
5363
|
+
requestor_vpc = VpcV2(self, "VpcB",
|
|
5364
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
5365
|
+
)
|
|
5366
|
+
|
|
5367
|
+
peering_connection = requestor_vpc.create_peering_connection("peeringConnection",
|
|
5368
|
+
acceptor_vpc=acceptor_vpc
|
|
5369
|
+
)
|
|
5370
|
+
|
|
5371
|
+
route_table = RouteTable(self, "RouteTable",
|
|
5372
|
+
vpc=requestor_vpc
|
|
5373
|
+
)
|
|
5374
|
+
|
|
5375
|
+
route_table.add_route("vpcPeeringRoute", "10.0.0.0/16", {"gateway": peering_connection})
|
|
5376
|
+
'''
|
|
5377
|
+
if __debug__:
|
|
5378
|
+
type_hints = typing.get_type_hints(_typecheckingstub__0af49af26f1090133d0d501835d377111e3de273232bb0049c4a5a90c4be9e69)
|
|
5379
|
+
check_type(argname="argument acceptor_vpc", value=acceptor_vpc, expected_type=type_hints["acceptor_vpc"])
|
|
5380
|
+
check_type(argname="argument peer_role_arn", value=peer_role_arn, expected_type=type_hints["peer_role_arn"])
|
|
5381
|
+
check_type(argname="argument vpc_peering_connection_name", value=vpc_peering_connection_name, expected_type=type_hints["vpc_peering_connection_name"])
|
|
5382
|
+
self._values: typing.Dict[builtins.str, typing.Any] = {
|
|
5383
|
+
"acceptor_vpc": acceptor_vpc,
|
|
5384
|
+
}
|
|
5385
|
+
if peer_role_arn is not None:
|
|
5386
|
+
self._values["peer_role_arn"] = peer_role_arn
|
|
5387
|
+
if vpc_peering_connection_name is not None:
|
|
5388
|
+
self._values["vpc_peering_connection_name"] = vpc_peering_connection_name
|
|
5389
|
+
|
|
5390
|
+
@builtins.property
|
|
5391
|
+
def acceptor_vpc(self) -> IVpcV2:
|
|
5392
|
+
'''(experimental) The VPC that is accepting the peering connection.
|
|
5393
|
+
|
|
5394
|
+
:stability: experimental
|
|
5395
|
+
'''
|
|
5396
|
+
result = self._values.get("acceptor_vpc")
|
|
5397
|
+
assert result is not None, "Required property 'acceptor_vpc' is missing"
|
|
5398
|
+
return typing.cast(IVpcV2, result)
|
|
5399
|
+
|
|
5400
|
+
@builtins.property
|
|
5401
|
+
def peer_role_arn(self) -> typing.Optional[builtins.str]:
|
|
5402
|
+
'''(experimental) The role arn created in the acceptor account.
|
|
5403
|
+
|
|
5404
|
+
:default: - no peerRoleArn needed if not cross account connection
|
|
5405
|
+
|
|
5406
|
+
:stability: experimental
|
|
5407
|
+
'''
|
|
5408
|
+
result = self._values.get("peer_role_arn")
|
|
5409
|
+
return typing.cast(typing.Optional[builtins.str], result)
|
|
5410
|
+
|
|
5411
|
+
@builtins.property
|
|
5412
|
+
def vpc_peering_connection_name(self) -> typing.Optional[builtins.str]:
|
|
5413
|
+
'''(experimental) The resource name of the peering connection.
|
|
5414
|
+
|
|
5415
|
+
:default: - peering connection provisioned without any name
|
|
5416
|
+
|
|
5417
|
+
:stability: experimental
|
|
5418
|
+
'''
|
|
5419
|
+
result = self._values.get("vpc_peering_connection_name")
|
|
5420
|
+
return typing.cast(typing.Optional[builtins.str], result)
|
|
5421
|
+
|
|
5422
|
+
def __eq__(self, rhs: typing.Any) -> builtins.bool:
|
|
5423
|
+
return isinstance(rhs, self.__class__) and rhs._values == self._values
|
|
5424
|
+
|
|
5425
|
+
def __ne__(self, rhs: typing.Any) -> builtins.bool:
|
|
5426
|
+
return not (rhs == self)
|
|
5427
|
+
|
|
5428
|
+
def __repr__(self) -> str:
|
|
5429
|
+
return "VPCPeeringConnectionOptions(%s)" % ", ".join(
|
|
5430
|
+
k + "=" + repr(v) for k, v in self._values.items()
|
|
5431
|
+
)
|
|
5432
|
+
|
|
5433
|
+
|
|
5434
|
+
@jsii.data_type(
|
|
5435
|
+
jsii_type="@aws-cdk/aws-ec2-alpha.VPCPeeringConnectionProps",
|
|
5436
|
+
jsii_struct_bases=[VPCPeeringConnectionOptions],
|
|
5437
|
+
name_mapping={
|
|
5438
|
+
"acceptor_vpc": "acceptorVpc",
|
|
5439
|
+
"peer_role_arn": "peerRoleArn",
|
|
5440
|
+
"vpc_peering_connection_name": "vpcPeeringConnectionName",
|
|
5441
|
+
"requestor_vpc": "requestorVpc",
|
|
5442
|
+
},
|
|
5443
|
+
)
|
|
5444
|
+
class VPCPeeringConnectionProps(VPCPeeringConnectionOptions):
|
|
5445
|
+
def __init__(
|
|
5446
|
+
self,
|
|
5447
|
+
*,
|
|
5448
|
+
acceptor_vpc: IVpcV2,
|
|
5449
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
5450
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
5451
|
+
requestor_vpc: IVpcV2,
|
|
5452
|
+
) -> None:
|
|
5453
|
+
'''(experimental) Properties to define a VPC peering connection.
|
|
5454
|
+
|
|
5455
|
+
:param acceptor_vpc: (experimental) The VPC that is accepting the peering connection.
|
|
5456
|
+
:param peer_role_arn: (experimental) The role arn created in the acceptor account. Default: - no peerRoleArn needed if not cross account connection
|
|
5457
|
+
:param vpc_peering_connection_name: (experimental) The resource name of the peering connection. Default: - peering connection provisioned without any name
|
|
5458
|
+
:param requestor_vpc: (experimental) The VPC that is requesting the peering connection.
|
|
5459
|
+
|
|
5460
|
+
:stability: experimental
|
|
5461
|
+
:exampleMetadata: fixture=_generated
|
|
5462
|
+
|
|
5463
|
+
Example::
|
|
5464
|
+
|
|
5465
|
+
# The code below shows an example of how to instantiate this type.
|
|
5466
|
+
# The values are placeholders you should change.
|
|
5467
|
+
import aws_cdk.aws_ec2_alpha as ec2_alpha
|
|
5468
|
+
|
|
5469
|
+
# vpc_v2: ec2_alpha.VpcV2
|
|
5470
|
+
|
|
5471
|
+
v_pCPeering_connection_props = ec2_alpha.VPCPeeringConnectionProps(
|
|
5472
|
+
acceptor_vpc=vpc_v2,
|
|
5473
|
+
requestor_vpc=vpc_v2,
|
|
5474
|
+
|
|
5475
|
+
# the properties below are optional
|
|
5476
|
+
peer_role_arn="peerRoleArn",
|
|
5477
|
+
vpc_peering_connection_name="vpcPeeringConnectionName"
|
|
5478
|
+
)
|
|
5479
|
+
'''
|
|
5480
|
+
if __debug__:
|
|
5481
|
+
type_hints = typing.get_type_hints(_typecheckingstub__aa9f45396d3362a2cfb477c193a94dfd41a69e0f8483a75944240a97be6a7658)
|
|
5482
|
+
check_type(argname="argument acceptor_vpc", value=acceptor_vpc, expected_type=type_hints["acceptor_vpc"])
|
|
5483
|
+
check_type(argname="argument peer_role_arn", value=peer_role_arn, expected_type=type_hints["peer_role_arn"])
|
|
5484
|
+
check_type(argname="argument vpc_peering_connection_name", value=vpc_peering_connection_name, expected_type=type_hints["vpc_peering_connection_name"])
|
|
5485
|
+
check_type(argname="argument requestor_vpc", value=requestor_vpc, expected_type=type_hints["requestor_vpc"])
|
|
5486
|
+
self._values: typing.Dict[builtins.str, typing.Any] = {
|
|
5487
|
+
"acceptor_vpc": acceptor_vpc,
|
|
5488
|
+
"requestor_vpc": requestor_vpc,
|
|
5489
|
+
}
|
|
5490
|
+
if peer_role_arn is not None:
|
|
5491
|
+
self._values["peer_role_arn"] = peer_role_arn
|
|
5492
|
+
if vpc_peering_connection_name is not None:
|
|
5493
|
+
self._values["vpc_peering_connection_name"] = vpc_peering_connection_name
|
|
5494
|
+
|
|
5495
|
+
@builtins.property
|
|
5496
|
+
def acceptor_vpc(self) -> IVpcV2:
|
|
5497
|
+
'''(experimental) The VPC that is accepting the peering connection.
|
|
5498
|
+
|
|
5499
|
+
:stability: experimental
|
|
5500
|
+
'''
|
|
5501
|
+
result = self._values.get("acceptor_vpc")
|
|
5502
|
+
assert result is not None, "Required property 'acceptor_vpc' is missing"
|
|
5503
|
+
return typing.cast(IVpcV2, result)
|
|
5504
|
+
|
|
5505
|
+
@builtins.property
|
|
5506
|
+
def peer_role_arn(self) -> typing.Optional[builtins.str]:
|
|
5507
|
+
'''(experimental) The role arn created in the acceptor account.
|
|
5508
|
+
|
|
5509
|
+
:default: - no peerRoleArn needed if not cross account connection
|
|
5510
|
+
|
|
5511
|
+
:stability: experimental
|
|
5512
|
+
'''
|
|
5513
|
+
result = self._values.get("peer_role_arn")
|
|
5514
|
+
return typing.cast(typing.Optional[builtins.str], result)
|
|
5515
|
+
|
|
5516
|
+
@builtins.property
|
|
5517
|
+
def vpc_peering_connection_name(self) -> typing.Optional[builtins.str]:
|
|
5518
|
+
'''(experimental) The resource name of the peering connection.
|
|
5519
|
+
|
|
5520
|
+
:default: - peering connection provisioned without any name
|
|
5521
|
+
|
|
5522
|
+
:stability: experimental
|
|
5523
|
+
'''
|
|
5524
|
+
result = self._values.get("vpc_peering_connection_name")
|
|
5525
|
+
return typing.cast(typing.Optional[builtins.str], result)
|
|
5526
|
+
|
|
5527
|
+
@builtins.property
|
|
5528
|
+
def requestor_vpc(self) -> IVpcV2:
|
|
5529
|
+
'''(experimental) The VPC that is requesting the peering connection.
|
|
5530
|
+
|
|
5531
|
+
:stability: experimental
|
|
5532
|
+
'''
|
|
5533
|
+
result = self._values.get("requestor_vpc")
|
|
5534
|
+
assert result is not None, "Required property 'requestor_vpc' is missing"
|
|
5535
|
+
return typing.cast(IVpcV2, result)
|
|
5536
|
+
|
|
5537
|
+
def __eq__(self, rhs: typing.Any) -> builtins.bool:
|
|
5538
|
+
return isinstance(rhs, self.__class__) and rhs._values == self._values
|
|
5539
|
+
|
|
5540
|
+
def __ne__(self, rhs: typing.Any) -> builtins.bool:
|
|
5541
|
+
return not (rhs == self)
|
|
5542
|
+
|
|
5543
|
+
def __repr__(self) -> str:
|
|
5544
|
+
return "VPCPeeringConnectionProps(%s)" % ", ".join(
|
|
5545
|
+
k + "=" + repr(v) for k, v in self._values.items()
|
|
5546
|
+
)
|
|
5547
|
+
|
|
5548
|
+
|
|
4997
5549
|
@jsii.implements(IRouteTarget)
|
|
4998
5550
|
class VPNGatewayV2(
|
|
4999
5551
|
_aws_cdk_ceddda9d.Resource,
|
|
@@ -5619,12 +6171,22 @@ class VpcV2Attributes:
|
|
|
5619
6171
|
|
|
5620
6172
|
stack = Stack()
|
|
5621
6173
|
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
vpc_id="mockVpcID",
|
|
6174
|
+
acceptor_vpc = VpcV2.from_vpc_v2_attributes(self, "acceptorVpc",
|
|
6175
|
+
vpc_id="vpc-XXXX",
|
|
5625
6176
|
vpc_cidr_block="10.0.0.0/16",
|
|
5626
|
-
|
|
5627
|
-
|
|
6177
|
+
region="us-east-2",
|
|
6178
|
+
owner_account_id="111111111111"
|
|
6179
|
+
)
|
|
6180
|
+
|
|
6181
|
+
acceptor_role_arn = "arn:aws:iam::111111111111:role/VpcPeeringRole"
|
|
6182
|
+
|
|
6183
|
+
requestor_vpc = VpcV2(self, "VpcB",
|
|
6184
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
6185
|
+
)
|
|
6186
|
+
|
|
6187
|
+
peering_connection = requestor_vpc.create_peering_connection("crossAccountCrossRegionPeering",
|
|
6188
|
+
acceptor_vpc=acceptor_vpc,
|
|
6189
|
+
peer_role_arn=acceptor_role_arn
|
|
5628
6190
|
)
|
|
5629
6191
|
'''
|
|
5630
6192
|
if __debug__:
|
|
@@ -6071,6 +6633,51 @@ class VpcV2Base(
|
|
|
6071
6633
|
|
|
6072
6634
|
return typing.cast(_aws_cdk_aws_ec2_ceddda9d.VpnConnection, jsii.invoke(self, "addVpnConnection", [id, options]))
|
|
6073
6635
|
|
|
6636
|
+
@jsii.member(jsii_name="createAcceptorVpcRole")
|
|
6637
|
+
def create_acceptor_vpc_role(
|
|
6638
|
+
self,
|
|
6639
|
+
requestor_account_id: builtins.str,
|
|
6640
|
+
) -> _aws_cdk_aws_iam_ceddda9d.Role:
|
|
6641
|
+
'''(experimental) Creates peering connection role for acceptor VPC.
|
|
6642
|
+
|
|
6643
|
+
:param requestor_account_id: -
|
|
6644
|
+
|
|
6645
|
+
:stability: experimental
|
|
6646
|
+
'''
|
|
6647
|
+
if __debug__:
|
|
6648
|
+
type_hints = typing.get_type_hints(_typecheckingstub__d6deac542ba364afef2787e14a37a31d64e7bfd81977c0fc72474f4cebb5afec)
|
|
6649
|
+
check_type(argname="argument requestor_account_id", value=requestor_account_id, expected_type=type_hints["requestor_account_id"])
|
|
6650
|
+
return typing.cast(_aws_cdk_aws_iam_ceddda9d.Role, jsii.invoke(self, "createAcceptorVpcRole", [requestor_account_id]))
|
|
6651
|
+
|
|
6652
|
+
@jsii.member(jsii_name="createPeeringConnection")
|
|
6653
|
+
def create_peering_connection(
|
|
6654
|
+
self,
|
|
6655
|
+
id: builtins.str,
|
|
6656
|
+
*,
|
|
6657
|
+
acceptor_vpc: IVpcV2,
|
|
6658
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
6659
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
6660
|
+
) -> VPCPeeringConnection:
|
|
6661
|
+
'''(experimental) Creates a peering connection.
|
|
6662
|
+
|
|
6663
|
+
:param id: -
|
|
6664
|
+
:param acceptor_vpc: (experimental) The VPC that is accepting the peering connection.
|
|
6665
|
+
:param peer_role_arn: (experimental) The role arn created in the acceptor account. Default: - no peerRoleArn needed if not cross account connection
|
|
6666
|
+
:param vpc_peering_connection_name: (experimental) The resource name of the peering connection. Default: - peering connection provisioned without any name
|
|
6667
|
+
|
|
6668
|
+
:stability: experimental
|
|
6669
|
+
'''
|
|
6670
|
+
if __debug__:
|
|
6671
|
+
type_hints = typing.get_type_hints(_typecheckingstub__13247ed9bcf578d2a1d3e5673f812980b1dc721ed9438b71961b232d8c9ee6b7)
|
|
6672
|
+
check_type(argname="argument id", value=id, expected_type=type_hints["id"])
|
|
6673
|
+
options = VPCPeeringConnectionOptions(
|
|
6674
|
+
acceptor_vpc=acceptor_vpc,
|
|
6675
|
+
peer_role_arn=peer_role_arn,
|
|
6676
|
+
vpc_peering_connection_name=vpc_peering_connection_name,
|
|
6677
|
+
)
|
|
6678
|
+
|
|
6679
|
+
return typing.cast(VPCPeeringConnection, jsii.invoke(self, "createPeeringConnection", [id, options]))
|
|
6680
|
+
|
|
6074
6681
|
@jsii.member(jsii_name="enableVpnGateway")
|
|
6075
6682
|
def enable_vpn_gateway(
|
|
6076
6683
|
self,
|
|
@@ -6732,22 +7339,22 @@ class VpcV2(
|
|
|
6732
7339
|
Example::
|
|
6733
7340
|
|
|
6734
7341
|
stack = Stack()
|
|
6735
|
-
my_vpc = VpcV2(self, "Vpc"
|
|
6736
|
-
|
|
6737
|
-
|
|
7342
|
+
my_vpc = VpcV2(self, "Vpc",
|
|
7343
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16"),
|
|
7344
|
+
secondary_address_blocks=[IpAddresses.amazon_provided_ipv6(
|
|
7345
|
+
cidr_block_name="AmazonProvided"
|
|
7346
|
+
)]
|
|
6738
7347
|
)
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
ipv4_cidr_block=IpCidr("10.0.0.0/24"),
|
|
6743
|
-
subnet_type=SubnetType.PUBLIC
|
|
7348
|
+
|
|
7349
|
+
eigw = EgressOnlyInternetGateway(self, "EIGW",
|
|
7350
|
+
vpc=my_vpc
|
|
6744
7351
|
)
|
|
6745
7352
|
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
subnet=subnet,
|
|
6749
|
-
connectivity_type=NatConnectivityType.PUBLIC
|
|
7353
|
+
route_table = RouteTable(self, "RouteTable",
|
|
7354
|
+
vpc=my_vpc
|
|
6750
7355
|
)
|
|
7356
|
+
|
|
7357
|
+
route_table.add_route("EIGW", "::/0", {"gateway": eigw})
|
|
6751
7358
|
'''
|
|
6752
7359
|
|
|
6753
7360
|
def __init__(
|
|
@@ -6915,7 +7522,7 @@ class VpcV2(
|
|
|
6915
7522
|
@builtins.property
|
|
6916
7523
|
@jsii.member(jsii_name="privateSubnets")
|
|
6917
7524
|
def private_subnets(self) -> typing.List[_aws_cdk_aws_ec2_ceddda9d.ISubnet]:
|
|
6918
|
-
'''(experimental)
|
|
7525
|
+
'''(experimental) Public Subnets that are part of this VPC.
|
|
6919
7526
|
|
|
6920
7527
|
:stability: experimental
|
|
6921
7528
|
'''
|
|
@@ -7049,6 +7656,9 @@ __all__ = [
|
|
|
7049
7656
|
"SubnetV2Attributes",
|
|
7050
7657
|
"SubnetV2Props",
|
|
7051
7658
|
"VPCCidrBlockattributes",
|
|
7659
|
+
"VPCPeeringConnection",
|
|
7660
|
+
"VPCPeeringConnectionOptions",
|
|
7661
|
+
"VPCPeeringConnectionProps",
|
|
7052
7662
|
"VPNGatewayV2",
|
|
7053
7663
|
"VPNGatewayV2Options",
|
|
7054
7664
|
"VPNGatewayV2Props",
|
|
@@ -7098,6 +7708,22 @@ def _typecheckingstub__1ab59e34a032c2ecbc5b1f46184e5eafc041fe87fd1c685e9d6723df4
|
|
|
7098
7708
|
"""Type checking stubs"""
|
|
7099
7709
|
pass
|
|
7100
7710
|
|
|
7711
|
+
def _typecheckingstub__cb54cb9dd15b7bc3477efe1017142f91e359c4d2220c0bd556b2b114780a28d4(
|
|
7712
|
+
requestor_account_id: builtins.str,
|
|
7713
|
+
) -> None:
|
|
7714
|
+
"""Type checking stubs"""
|
|
7715
|
+
pass
|
|
7716
|
+
|
|
7717
|
+
def _typecheckingstub__4919a255fea8cc4db70fd26400dd951f53e86d9e4e3aa3b925f0e5fc7b14d4b5(
|
|
7718
|
+
id: builtins.str,
|
|
7719
|
+
*,
|
|
7720
|
+
acceptor_vpc: IVpcV2,
|
|
7721
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
7722
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
7723
|
+
) -> None:
|
|
7724
|
+
"""Type checking stubs"""
|
|
7725
|
+
pass
|
|
7726
|
+
|
|
7101
7727
|
def _typecheckingstub__a1ed9b26ff938b529db1af6f12978e1aa57b9cdaf5a5c589675cf7b8f2c6fe6a(
|
|
7102
7728
|
scope: _constructs_77d1e7e8.Construct,
|
|
7103
7729
|
id: builtins.str,
|
|
@@ -7391,6 +8017,37 @@ def _typecheckingstub__4302f03d1c3aa687fb9a6d3011f239c94d844badf36d9d2e8270a543f
|
|
|
7391
8017
|
"""Type checking stubs"""
|
|
7392
8018
|
pass
|
|
7393
8019
|
|
|
8020
|
+
def _typecheckingstub__adba7b6a63c8eb67b053fce652ae79528cbaae45a3febbc3dde851a8a9afa655(
|
|
8021
|
+
scope: _constructs_77d1e7e8.Construct,
|
|
8022
|
+
id: builtins.str,
|
|
8023
|
+
*,
|
|
8024
|
+
requestor_vpc: IVpcV2,
|
|
8025
|
+
acceptor_vpc: IVpcV2,
|
|
8026
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
8027
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
8028
|
+
) -> None:
|
|
8029
|
+
"""Type checking stubs"""
|
|
8030
|
+
pass
|
|
8031
|
+
|
|
8032
|
+
def _typecheckingstub__0af49af26f1090133d0d501835d377111e3de273232bb0049c4a5a90c4be9e69(
|
|
8033
|
+
*,
|
|
8034
|
+
acceptor_vpc: IVpcV2,
|
|
8035
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
8036
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
8037
|
+
) -> None:
|
|
8038
|
+
"""Type checking stubs"""
|
|
8039
|
+
pass
|
|
8040
|
+
|
|
8041
|
+
def _typecheckingstub__aa9f45396d3362a2cfb477c193a94dfd41a69e0f8483a75944240a97be6a7658(
|
|
8042
|
+
*,
|
|
8043
|
+
acceptor_vpc: IVpcV2,
|
|
8044
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
8045
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
8046
|
+
requestor_vpc: IVpcV2,
|
|
8047
|
+
) -> None:
|
|
8048
|
+
"""Type checking stubs"""
|
|
8049
|
+
pass
|
|
8050
|
+
|
|
7394
8051
|
def _typecheckingstub__99ebb03388deee94929850a6302ea70455c70b08fdbc048c0ad431df4f5d7bff(
|
|
7395
8052
|
scope: _constructs_77d1e7e8.Construct,
|
|
7396
8053
|
id: builtins.str,
|
|
@@ -7535,6 +8192,22 @@ def _typecheckingstub__f7bea01b8937a479893951a9d249dafac5eb677589e384aaf4163753c
|
|
|
7535
8192
|
"""Type checking stubs"""
|
|
7536
8193
|
pass
|
|
7537
8194
|
|
|
8195
|
+
def _typecheckingstub__d6deac542ba364afef2787e14a37a31d64e7bfd81977c0fc72474f4cebb5afec(
|
|
8196
|
+
requestor_account_id: builtins.str,
|
|
8197
|
+
) -> None:
|
|
8198
|
+
"""Type checking stubs"""
|
|
8199
|
+
pass
|
|
8200
|
+
|
|
8201
|
+
def _typecheckingstub__13247ed9bcf578d2a1d3e5673f812980b1dc721ed9438b71961b232d8c9ee6b7(
|
|
8202
|
+
id: builtins.str,
|
|
8203
|
+
*,
|
|
8204
|
+
acceptor_vpc: IVpcV2,
|
|
8205
|
+
peer_role_arn: typing.Optional[builtins.str] = None,
|
|
8206
|
+
vpc_peering_connection_name: typing.Optional[builtins.str] = None,
|
|
8207
|
+
) -> None:
|
|
8208
|
+
"""Type checking stubs"""
|
|
8209
|
+
pass
|
|
8210
|
+
|
|
7538
8211
|
def _typecheckingstub__072197b57e17e2499221b9aaf0906eb11fd406cafb9318f2400beeef9e8484d1(
|
|
7539
8212
|
value: builtins.bool,
|
|
7540
8213
|
) -> None:
|
|
@@ -33,9 +33,9 @@ import constructs._jsii
|
|
|
33
33
|
|
|
34
34
|
__jsii_assembly__ = jsii.JSIIAssembly.load(
|
|
35
35
|
"@aws-cdk/aws-ec2-alpha",
|
|
36
|
-
"2.
|
|
36
|
+
"2.171.0-alpha.0",
|
|
37
37
|
__name__[0:-6],
|
|
38
|
-
"aws-ec2-alpha@2.
|
|
38
|
+
"aws-ec2-alpha@2.171.0-alpha.0.jsii.tgz",
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
__all__ = [
|
|
Binary file
|
{aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info → aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: aws-cdk.aws-ec2-alpha
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.171.0a0
|
|
4
4
|
Summary: The CDK construct library for VPC V2
|
|
5
5
|
Home-page: https://github.com/aws/aws-cdk
|
|
6
6
|
Author: Amazon Web Services
|
|
@@ -23,7 +23,7 @@ Requires-Python: ~=3.8
|
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
25
|
License-File: NOTICE
|
|
26
|
-
Requires-Dist: aws-cdk-lib<3.0.0,>=2.
|
|
26
|
+
Requires-Dist: aws-cdk-lib<3.0.0,>=2.171.0
|
|
27
27
|
Requires-Dist: constructs<11.0.0,>=10.0.0
|
|
28
28
|
Requires-Dist: jsii<2.0.0,>=1.104.0
|
|
29
29
|
Requires-Dist: publication>=0.0.3
|
|
@@ -251,6 +251,155 @@ Route(self, "DynamoDBRoute",
|
|
|
251
251
|
)
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
+
## VPC Peering Connection
|
|
255
|
+
|
|
256
|
+
VPC peering connection allows you to connect two VPCs and route traffic between them using private IP addresses. The VpcV2 construct supports creating VPC peering connections through the `VPCPeeringConnection` construct from the `route` module.
|
|
257
|
+
|
|
258
|
+
Peering Connection cannot be established between two VPCs with overlapping CIDR ranges. Please make sure the two VPC CIDRs do not overlap with each other else it will throw an error.
|
|
259
|
+
|
|
260
|
+
For more information, see [What is VPC peering?](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html).
|
|
261
|
+
|
|
262
|
+
The following show examples of how to create a peering connection between two VPCs for all possible combinations of same-account or cross-account, and same-region or cross-region configurations.
|
|
263
|
+
|
|
264
|
+
Note: You cannot create a VPC peering connection between VPCs that have matching or overlapping CIDR blocks
|
|
265
|
+
|
|
266
|
+
**Case 1: Same Account and Same Region Peering Connection**
|
|
267
|
+
|
|
268
|
+
```python
|
|
269
|
+
stack = Stack()
|
|
270
|
+
|
|
271
|
+
vpc_a = VpcV2(self, "VpcA",
|
|
272
|
+
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
vpc_b = VpcV2(self, "VpcB",
|
|
276
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
peering_connection = vpc_a.create_peering_connection("sameAccountSameRegionPeering",
|
|
280
|
+
acceptor_vpc=vpc_b
|
|
281
|
+
)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Case 2: Same Account and Cross Region Peering Connection**
|
|
285
|
+
|
|
286
|
+
There is no difference from Case 1 when calling `createPeeringConnection`. The only change is that one of the VPCs are created in another stack with a different region. To establish cross region VPC peering connection, acceptorVpc needs to be imported to the requestor VPC stack using `fromVpcV2Attributes` method.
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
app = App()
|
|
290
|
+
|
|
291
|
+
stack_a = Stack(app, "VpcStackA", env=Environment(account="000000000000", region="us-east-1"))
|
|
292
|
+
stack_b = Stack(app, "VpcStackB", env=Environment(account="000000000000", region="us-west-2"))
|
|
293
|
+
|
|
294
|
+
vpc_a = VpcV2(stack_a, "VpcA",
|
|
295
|
+
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
VpcV2(stack_b, "VpcB",
|
|
299
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
vpc_b = VpcV2.from_vpc_v2_attributes(stack_a, "ImportedVpcB",
|
|
303
|
+
vpc_id="MockVpcBid",
|
|
304
|
+
vpc_cidr_block="10.1.0.0/16",
|
|
305
|
+
region="us-west-2",
|
|
306
|
+
owner_account_id="000000000000"
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
peering_connection = vpc_a.create_peering_connection("sameAccountCrossRegionPeering",
|
|
310
|
+
acceptor_vpc=vpc_b
|
|
311
|
+
)
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Case 3: Cross Account Peering Connection**
|
|
315
|
+
|
|
316
|
+
For cross-account connections, the acceptor account needs an IAM role that grants the requestor account permission to initiate the connection. Create a new IAM role in the acceptor account using method `createAcceptorVpcRole` to provide the necessary permissions.
|
|
317
|
+
|
|
318
|
+
Once role is created in account, provide role arn for field `peerRoleArn` under method `createPeeringConnection`
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
stack = Stack()
|
|
322
|
+
|
|
323
|
+
acceptor_vpc = VpcV2(self, "VpcA",
|
|
324
|
+
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
acceptor_role_arn = acceptor_vpc.create_acceptor_vpc_role("000000000000")
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
After creating an IAM role in the acceptor account, we can initiate the peering connection request from the requestor VPC. Import accpeptorVpc to the stack using `fromVpcV2Attributes` method, it is recommended to specify owner account id of the acceptor VPC in case of cross account peering connection, if acceptor VPC is hosted in different region provide region value for import as well.
|
|
331
|
+
The following code snippet demonstrates how to set up VPC peering between two VPCs in different AWS accounts using CDK:
|
|
332
|
+
|
|
333
|
+
```python
|
|
334
|
+
stack = Stack()
|
|
335
|
+
|
|
336
|
+
acceptor_vpc = VpcV2.from_vpc_v2_attributes(self, "acceptorVpc",
|
|
337
|
+
vpc_id="vpc-XXXX",
|
|
338
|
+
vpc_cidr_block="10.0.0.0/16",
|
|
339
|
+
region="us-east-2",
|
|
340
|
+
owner_account_id="111111111111"
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
acceptor_role_arn = "arn:aws:iam::111111111111:role/VpcPeeringRole"
|
|
344
|
+
|
|
345
|
+
requestor_vpc = VpcV2(self, "VpcB",
|
|
346
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
peering_connection = requestor_vpc.create_peering_connection("crossAccountCrossRegionPeering",
|
|
350
|
+
acceptor_vpc=acceptor_vpc,
|
|
351
|
+
peer_role_arn=acceptor_role_arn
|
|
352
|
+
)
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Route Table Configuration
|
|
356
|
+
|
|
357
|
+
After establishing the VPC peering connection, routes must be added to the respective route tables in the VPCs to enable traffic flow. If a route is added to the requestor stack, information will be able to flow from the requestor VPC to the acceptor VPC, but not in the reverse direction. For bi-directional communication, routes need to be added in both VPCs from their respective stacks.
|
|
358
|
+
|
|
359
|
+
For more information, see [Update your route tables for a VPC peering connection](https://docs.aws.amazon.com/vpc/latest/peering/vpc-peering-routing.html).
|
|
360
|
+
|
|
361
|
+
```python
|
|
362
|
+
stack = Stack()
|
|
363
|
+
|
|
364
|
+
acceptor_vpc = VpcV2(self, "VpcA",
|
|
365
|
+
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
requestor_vpc = VpcV2(self, "VpcB",
|
|
369
|
+
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
peering_connection = requestor_vpc.create_peering_connection("peeringConnection",
|
|
373
|
+
acceptor_vpc=acceptor_vpc
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
route_table = RouteTable(self, "RouteTable",
|
|
377
|
+
vpc=requestor_vpc
|
|
378
|
+
)
|
|
379
|
+
|
|
380
|
+
route_table.add_route("vpcPeeringRoute", "10.0.0.0/16", {"gateway": peering_connection})
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
This can also be done using AWS CLI. For more information, see [create-route](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-route.html).
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
# Add a route to the requestor VPC route table
|
|
387
|
+
aws ec2 create-route --route-table-id rtb-requestor --destination-cidr-block 10.0.0.0/16 --vpc-peering-connection-id pcx-xxxxxxxx
|
|
388
|
+
|
|
389
|
+
# For bi-directional add a route in the acceptor vpc account as well
|
|
390
|
+
aws ec2 create-route --route-table-id rtb-acceptor --destination-cidr-block 10.1.0.0/16 --vpc-peering-connection-id pcx-xxxxxxxx
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Deleting the Peering Connection
|
|
394
|
+
|
|
395
|
+
To delete a VPC peering connection, use the following command:
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
aws ec2 delete-vpc-peering-connection --vpc-peering-connection-id pcx-xxxxxxxx
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
For more information, see [Delete a VPC peering connection](https://docs.aws.amazon.com/vpc/latest/peering/create-vpc-peering-connection.html#delete-vpc-peering-connection).
|
|
402
|
+
|
|
254
403
|
## Adding Egress-Only Internet Gateway to VPC
|
|
255
404
|
|
|
256
405
|
An egress-only internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows outbound communication over IPv6 from instances in your VPC to the internet, and prevents the internet from initiating an IPv6 connection with your instances.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
aws_cdk/aws_ec2_alpha/__init__.py,sha256=wkTyFKJ5P8YRGMiSoBE5kuFx2pVMKTkGptIdKOCPHFA,357740
|
|
2
|
+
aws_cdk/aws_ec2_alpha/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
3
|
+
aws_cdk/aws_ec2_alpha/_jsii/__init__.py,sha256=XyWeGPuHmVUC4gwmzvRFnl83hGCGnriwO9aZVWfxuW0,1479
|
|
4
|
+
aws_cdk/aws_ec2_alpha/_jsii/aws-ec2-alpha@2.171.0-alpha.0.jsii.tgz,sha256=iv61GZMGvOd18XyFPdTbp1qAeC8CN1zlL_bW0Hk4OFQ,177523
|
|
5
|
+
aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info/LICENSE,sha256=kEDF86xJUQh1E9M7UPKKbHepBEdFxIUyoGfTwQB7zKg,11391
|
|
6
|
+
aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info/METADATA,sha256=xrz_89OChdAGaQrbt3Gb0reQ1Ha0pHKxvD3qdYa4zeA,25153
|
|
7
|
+
aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info/NOTICE,sha256=dXf56qvx2VDNCaqiRscOD2IH5GbmqbnKRzroZCeLtaQ,113
|
|
8
|
+
aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
9
|
+
aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info/top_level.txt,sha256=1TALAKbuUGsMSrfKWEf268lySCmcqSEO6cDYe_XlLHM,8
|
|
10
|
+
aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info/RECORD,,
|
|
Binary file
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
aws_cdk/aws_ec2_alpha/__init__.py,sha256=CiLl22hgKUonbjTQN3xMCJbyO0X_L0kmEx5iMFvUFHw,329774
|
|
2
|
-
aws_cdk/aws_ec2_alpha/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
3
|
-
aws_cdk/aws_ec2_alpha/_jsii/__init__.py,sha256=Rw3Jze8O4q60vAiqcVWS2GLVZFhRC4IpP_u4r5J98OA,1479
|
|
4
|
-
aws_cdk/aws_ec2_alpha/_jsii/aws-ec2-alpha@2.169.0-alpha.0.jsii.tgz,sha256=hLBCjIRmXlnJn-QQoa1BSsNoX3uIzuMoqS9j60ru_jQ,164686
|
|
5
|
-
aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info/LICENSE,sha256=kEDF86xJUQh1E9M7UPKKbHepBEdFxIUyoGfTwQB7zKg,11391
|
|
6
|
-
aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info/METADATA,sha256=XDka9o49qEq8XIv4OK1VIWuvZTo9IY_EsR84ZgGQtX8,19145
|
|
7
|
-
aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info/NOTICE,sha256=dXf56qvx2VDNCaqiRscOD2IH5GbmqbnKRzroZCeLtaQ,113
|
|
8
|
-
aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
|
|
9
|
-
aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info/top_level.txt,sha256=1TALAKbuUGsMSrfKWEf268lySCmcqSEO6cDYe_XlLHM,8
|
|
10
|
-
aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info/RECORD,,
|
{aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info → aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info}/LICENSE
RENAMED
|
File without changes
|
{aws_cdk.aws_ec2_alpha-2.169.0a0.dist-info → aws_cdk.aws_ec2_alpha-2.171.0a0.dist-info}/NOTICE
RENAMED
|
File without changes
|
|
File without changes
|