aws-cdk.aws-ec2-alpha 2.168.0a0__tar.gz → 2.170.0a0__tar.gz

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.

Files changed (18) hide show
  1. {aws_cdk_aws_ec2_alpha-2.168.0a0/src/aws_cdk.aws_ec2_alpha.egg-info → aws_cdk_aws_ec2_alpha-2.170.0a0}/PKG-INFO +151 -2
  2. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/README.md +149 -0
  3. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/setup.py +3 -3
  4. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/src/aws_cdk/aws_ec2_alpha/__init__.py +691 -18
  5. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/src/aws_cdk/aws_ec2_alpha/_jsii/__init__.py +2 -2
  6. aws_cdk_aws_ec2_alpha-2.170.0a0/src/aws_cdk/aws_ec2_alpha/_jsii/aws-ec2-alpha@2.170.0-alpha.0.jsii.tgz +0 -0
  7. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0/src/aws_cdk.aws_ec2_alpha.egg-info}/PKG-INFO +151 -2
  8. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/src/aws_cdk.aws_ec2_alpha.egg-info/SOURCES.txt +1 -1
  9. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/src/aws_cdk.aws_ec2_alpha.egg-info/requires.txt +1 -1
  10. aws_cdk_aws_ec2_alpha-2.168.0a0/src/aws_cdk/aws_ec2_alpha/_jsii/aws-ec2-alpha@2.168.0-alpha.0.jsii.tgz +0 -0
  11. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/LICENSE +0 -0
  12. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/MANIFEST.in +0 -0
  13. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/NOTICE +0 -0
  14. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/pyproject.toml +0 -0
  15. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/setup.cfg +0 -0
  16. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/src/aws_cdk/aws_ec2_alpha/py.typed +0 -0
  17. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/src/aws_cdk.aws_ec2_alpha.egg-info/dependency_links.txt +0 -0
  18. {aws_cdk_aws_ec2_alpha-2.168.0a0 → aws_cdk_aws_ec2_alpha-2.170.0a0}/src/aws_cdk.aws_ec2_alpha.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aws-cdk.aws-ec2-alpha
3
- Version: 2.168.0a0
3
+ Version: 2.170.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.168.0
26
+ Requires-Dist: aws-cdk-lib<3.0.0,>=2.170.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.
@@ -220,6 +220,155 @@ Route(self, "DynamoDBRoute",
220
220
  )
221
221
  ```
222
222
 
223
+ ## VPC Peering Connection
224
+
225
+ 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.
226
+
227
+ 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.
228
+
229
+ For more information, see [What is VPC peering?](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html).
230
+
231
+ 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.
232
+
233
+ Note: You cannot create a VPC peering connection between VPCs that have matching or overlapping CIDR blocks
234
+
235
+ **Case 1: Same Account and Same Region Peering Connection**
236
+
237
+ ```python
238
+ stack = Stack()
239
+
240
+ vpc_a = VpcV2(self, "VpcA",
241
+ primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
242
+ )
243
+
244
+ vpc_b = VpcV2(self, "VpcB",
245
+ primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
246
+ )
247
+
248
+ peering_connection = vpc_a.create_peering_connection("sameAccountSameRegionPeering",
249
+ acceptor_vpc=vpc_b
250
+ )
251
+ ```
252
+
253
+ **Case 2: Same Account and Cross Region Peering Connection**
254
+
255
+ 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.
256
+
257
+ ```python
258
+ app = App()
259
+
260
+ stack_a = Stack(app, "VpcStackA", env=Environment(account="000000000000", region="us-east-1"))
261
+ stack_b = Stack(app, "VpcStackB", env=Environment(account="000000000000", region="us-west-2"))
262
+
263
+ vpc_a = VpcV2(stack_a, "VpcA",
264
+ primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
265
+ )
266
+
267
+ VpcV2(stack_b, "VpcB",
268
+ primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
269
+ )
270
+
271
+ vpc_b = VpcV2.from_vpc_v2_attributes(stack_a, "ImportedVpcB",
272
+ vpc_id="MockVpcBid",
273
+ vpc_cidr_block="10.1.0.0/16",
274
+ region="us-west-2",
275
+ owner_account_id="000000000000"
276
+ )
277
+
278
+ peering_connection = vpc_a.create_peering_connection("sameAccountCrossRegionPeering",
279
+ acceptor_vpc=vpc_b
280
+ )
281
+ ```
282
+
283
+ **Case 3: Cross Account Peering Connection**
284
+
285
+ 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.
286
+
287
+ Once role is created in account, provide role arn for field `peerRoleArn` under method `createPeeringConnection`
288
+
289
+ ```python
290
+ stack = Stack()
291
+
292
+ acceptor_vpc = VpcV2(self, "VpcA",
293
+ primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
294
+ )
295
+
296
+ acceptor_role_arn = acceptor_vpc.create_acceptor_vpc_role("000000000000")
297
+ ```
298
+
299
+ 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.
300
+ The following code snippet demonstrates how to set up VPC peering between two VPCs in different AWS accounts using CDK:
301
+
302
+ ```python
303
+ stack = Stack()
304
+
305
+ acceptor_vpc = VpcV2.from_vpc_v2_attributes(self, "acceptorVpc",
306
+ vpc_id="vpc-XXXX",
307
+ vpc_cidr_block="10.0.0.0/16",
308
+ region="us-east-2",
309
+ owner_account_id="111111111111"
310
+ )
311
+
312
+ acceptor_role_arn = "arn:aws:iam::111111111111:role/VpcPeeringRole"
313
+
314
+ requestor_vpc = VpcV2(self, "VpcB",
315
+ primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
316
+ )
317
+
318
+ peering_connection = requestor_vpc.create_peering_connection("crossAccountCrossRegionPeering",
319
+ acceptor_vpc=acceptor_vpc,
320
+ peer_role_arn=acceptor_role_arn
321
+ )
322
+ ```
323
+
324
+ ### Route Table Configuration
325
+
326
+ 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.
327
+
328
+ 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).
329
+
330
+ ```python
331
+ stack = Stack()
332
+
333
+ acceptor_vpc = VpcV2(self, "VpcA",
334
+ primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
335
+ )
336
+
337
+ requestor_vpc = VpcV2(self, "VpcB",
338
+ primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
339
+ )
340
+
341
+ peering_connection = requestor_vpc.create_peering_connection("peeringConnection",
342
+ acceptor_vpc=acceptor_vpc
343
+ )
344
+
345
+ route_table = RouteTable(self, "RouteTable",
346
+ vpc=requestor_vpc
347
+ )
348
+
349
+ route_table.add_route("vpcPeeringRoute", "10.0.0.0/16", {"gateway": peering_connection})
350
+ ```
351
+
352
+ 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).
353
+
354
+ ```bash
355
+ # Add a route to the requestor VPC route table
356
+ aws ec2 create-route --route-table-id rtb-requestor --destination-cidr-block 10.0.0.0/16 --vpc-peering-connection-id pcx-xxxxxxxx
357
+
358
+ # For bi-directional add a route in the acceptor vpc account as well
359
+ aws ec2 create-route --route-table-id rtb-acceptor --destination-cidr-block 10.1.0.0/16 --vpc-peering-connection-id pcx-xxxxxxxx
360
+ ```
361
+
362
+ ### Deleting the Peering Connection
363
+
364
+ To delete a VPC peering connection, use the following command:
365
+
366
+ ```bash
367
+ aws ec2 delete-vpc-peering-connection --vpc-peering-connection-id pcx-xxxxxxxx
368
+ ```
369
+
370
+ 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).
371
+
223
372
  ## Adding Egress-Only Internet Gateway to VPC
224
373
 
225
374
  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.
@@ -5,7 +5,7 @@ kwargs = json.loads(
5
5
  """
6
6
  {
7
7
  "name": "aws-cdk.aws-ec2-alpha",
8
- "version": "2.168.0.a0",
8
+ "version": "2.170.0.a0",
9
9
  "description": "The CDK construct library for VPC V2",
10
10
  "license": "Apache-2.0",
11
11
  "url": "https://github.com/aws/aws-cdk",
@@ -26,7 +26,7 @@ kwargs = json.loads(
26
26
  ],
27
27
  "package_data": {
28
28
  "aws_cdk.aws_ec2_alpha._jsii": [
29
- "aws-ec2-alpha@2.168.0-alpha.0.jsii.tgz"
29
+ "aws-ec2-alpha@2.170.0-alpha.0.jsii.tgz"
30
30
  ],
31
31
  "aws_cdk.aws_ec2_alpha": [
32
32
  "py.typed"
@@ -34,7 +34,7 @@ kwargs = json.loads(
34
34
  },
35
35
  "python_requires": "~=3.8",
36
36
  "install_requires": [
37
- "aws-cdk-lib>=2.168.0, <3.0.0",
37
+ "aws-cdk-lib>=2.170.0, <3.0.0",
38
38
  "constructs>=10.0.0, <11.0.0",
39
39
  "jsii>=1.104.0, <2.0.0",
40
40
  "publication>=0.0.3",