Skip to content

Commit b83e807

Browse files
authored
Merge branch 'main' into enum-update/static-mapping-update
2 parents a081026 + 4ea004d commit b83e807

File tree

167 files changed

+1977
-578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+1977
-578
lines changed

.github/workflows/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ Owner: CDK support team
9292
patch file for downloading.
9393
Owner: Core CDK team
9494

95+
### Yarn Upgrader for deps needing manual work
96+
97+
[yarn-upgrade-need-manual-work.yml](yarn-upgrade-need-manual-work.yml): Upgrades specific dependencies that require manual intervention and creates a PR for review.
98+
For example, some dependency upgrades require manual updates to the integ test snapshots.
99+
Owner: Core CDK team
100+
95101
### AWS Service Spec Update
96102

97103
[spec-update.yml](spec-update.yml): Updates AWS Service Spec and related packages to their latest versions
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Yarn Upgrade Dependencies Requiring Intervention
2+
# This workflow upgrade npm dependencies that will require manual work. For example, `@aws-cdk/asset-awscli-v1` upgrade always require manually updating snapshots.
3+
# When adding deps in this workflow, we must also exclude them in the Yarn Upgrade workflow. This is so that the PR from that workflow can be kept clean (i.e. does not need manual update).
4+
# See this line on how to exclude deps: https://github.com/aws/aws-cdk/blob/ce7b30775f354c7de774f73c5f8dedd9ce7530d3/.github/workflows/yarn-upgrade.yml#L61
5+
# If this proves to be too cumbersome, we can refactor both workflow to reference the deps list from a single place.
6+
7+
on:
8+
schedule:
9+
# Every wednesday at 13:37 UTC
10+
- cron: 37 13 * * 3
11+
workflow_dispatch: {}
12+
13+
# For multiple dependencies, do `DEPS_TO_UPGRADE:"p1 p2 p3"`
14+
env:
15+
DEPS_TO_UPGRADE: "@aws-cdk/asset-awscli-v1"
16+
17+
jobs:
18+
upgrade:
19+
name: Yarn Upgrade
20+
permissions:
21+
contents: read
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Check Out
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Node
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: "*"
31+
env:
32+
NODE_OPTIONS: "--max-old-space-size=8196 --experimental-worker ${NODE_OPTIONS:-}"
33+
34+
- name: Locate Yarn cache
35+
id: yarn-cache
36+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
37+
38+
- name: Restore Yarn cache
39+
uses: actions/cache@v4
40+
with:
41+
path: ${{ steps.yarn-cache.outputs.dir }}
42+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
43+
restore-keys: |-
44+
${{ runner.os }}-yarn-
45+
- name: Yarn Install
46+
run: yarn install --frozen-lockfile
47+
- name: Install Tools
48+
run: |-
49+
npm -g install lerna npm-check-updates
50+
- name: Run "ncu -u"
51+
run: |-
52+
# Convert space-separated string to comma-separated string for the filter
53+
FILTER=$(echo "$DEPS_TO_UPGRADE" | tr ' ' ',')
54+
lerna exec --parallel ncu -- --upgrade --filter="$FILTER" --target=minor
55+
56+
- name: Run "yarn upgrade"
57+
run: |
58+
echo "Upgrading dependencies: $DEPS_TO_UPGRADE"
59+
yarn upgrade $DEPS_TO_UPGRADE --exact
60+
61+
# Next, create and upload the changes as a patch file. This will later be downloaded to create a pull request
62+
# Creating a pull request requires write permissions and it's best to keep write privileges isolated.
63+
- name: Create Patch
64+
run: |-
65+
git add .
66+
git diff --binary --patch --staged > ${{ runner.temp }}/upgrade.patch
67+
68+
- name: Upload Patch
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: upgrade.patch
72+
path: ${{ runner.temp }}/upgrade.patch
73+
74+
pr:
75+
name: Create Pull Request
76+
needs: upgrade
77+
permissions:
78+
contents: write
79+
pull-requests: write
80+
runs-on: ubuntu-latest
81+
steps:
82+
- name: Check Out
83+
uses: actions/checkout@v4
84+
85+
- name: Download patch
86+
uses: actions/download-artifact@v4
87+
with:
88+
name: upgrade.patch
89+
path: ${{ runner.temp }}
90+
91+
- name: Apply patch
92+
run: '[ -s ${{ runner.temp }}/upgrade.patch ] && git apply --binary ${{ runner.temp
93+
}}/upgrade.patch || echo "Empty patch. Skipping."'
94+
95+
- name: Make Pull Request
96+
uses: peter-evans/create-pull-request@v7
97+
with:
98+
# Git commit details
99+
branch: automation/yarn-upgrade-dependencies-requiring-intervention
100+
author: aws-cdk-automation <aws-cdk-automation@users.noreply.github.com>
101+
commit-message: |-
102+
chore: npm-check-updates && yarn upgrade
103+
Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date.
104+
# Pull Request details
105+
title: 'chore: yarn upgrade dependencies requiring intervention'
106+
body: |-
107+
Ran npm-check-updates and yarn upgrade for the following dependencies:
108+
```
109+
${{ env.DEPS_TO_UPGRADE }}
110+
```
111+
Checkout this branch and run integration tests locally to update snapshots.
112+
```
113+
(cd packages/@aws-cdk-testing/framework-integ && yarn integ --update-on-failed)
114+
```
115+
See https://www.npmjs.com/package/@aws-cdk/integ-runner for more integ runner options.
116+
labels: contribution/core,dependencies
117+
team-reviewers: aws-cdk-team
118+
# Github prevents further Github actions to be run if the default Github token is used.
119+
# Instead use a privileged token here, so further GH actions can be triggered on this PR.
120+
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}

packages/@aws-cdk/aws-ec2-alpha/lib/route.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { CfnEIP, CfnEgressOnlyInternetGateway, CfnInternetGateway, CfnNatGateway, CfnVPCPeeringConnection, CfnRoute, CfnRouteTable, CfnVPCGatewayAttachment, CfnVPNGateway, CfnVPNGatewayRoutePropagation, GatewayVpcEndpoint, IRouteTable, IVpcEndpoint, RouterType } from 'aws-cdk-lib/aws-ec2';
22
import { Construct, IDependable } from 'constructs';
3-
import { Annotations, Duration, IResource, Resource, Tags, ValidationError } from 'aws-cdk-lib/core';
3+
import { Annotations, Duration, FeatureFlags, IResource, Resource, Tags, ValidationError } from 'aws-cdk-lib/core';
44
import { IVpcV2, VPNGatewayV2Options } from './vpc-v2-base';
55
import { NetworkUtils, allRouteTableIds, CidrBlock } from './util';
66
import { ISubnetV2 } from './subnet-v2';
77
import { addConstructMetadata, MethodMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
8+
import { cx_api } from 'aws-cdk-lib';
89

910
/**
1011
* Indicates whether the NAT gateway supports public or private connectivity.
@@ -289,13 +290,18 @@ export class InternetGateway extends Resource implements IRouteTarget {
289290
this.resource = new CfnInternetGateway(this, 'IGW', {});
290291
this.node.defaultChild = this.resource;
291292

292-
this.routerTargetId = this.resource.attrInternetGatewayId;
293+
this.routerTargetId = FeatureFlags.of(this).isEnabled(cx_api.USE_RESOURCEID_FOR_VPCV2_MIGRATION) ?
294+
this.resource.ref : this.resource.attrInternetGatewayId;
293295
this.vpcId = props.vpc.vpcId;
294296

295297
if (props.internetGatewayName) {
296298
Tags.of(this).add(NAME_TAG, props.internetGatewayName);
297299
}
298300

301+
if (props.vpc.vpcName) {
302+
Tags.of(this).add('Name', props.vpc.vpcName);
303+
}
304+
299305
new CfnVPCGatewayAttachment(this, 'GWAttachment', {
300306
vpcId: this.vpcId,
301307
internetGatewayId: this.routerTargetId,
@@ -426,6 +432,11 @@ export class NatGateway extends Resource implements IRouteTarget {
426432
*/
427433
public readonly resource: CfnNatGateway;
428434

435+
/**
436+
* Elastic IP created for allocation
437+
*/
438+
public readonly eip?: CfnEIP;
439+
429440
constructor(scope: Construct, id: string, props: NatGatewayProps) {
430441
super(scope, id);
431442
// Enhanced CDK Analytics Telemetry
@@ -450,10 +461,10 @@ export class NatGateway extends Resource implements IRouteTarget {
450461
var aId: string | undefined;
451462
if (this.connectivityType === NatConnectivityType.PUBLIC) {
452463
if (!props.allocationId) {
453-
let eip = new CfnEIP(this, 'EIP', {
464+
this.eip = new CfnEIP(this, 'EIP', {
454465
domain: 'vpc',
455466
});
456-
aId = eip.attrAllocationId;
467+
aId = this.eip.attrAllocationId;
457468
} else {
458469
aId = props.allocationId;
459470
}
@@ -466,11 +477,14 @@ export class NatGateway extends Resource implements IRouteTarget {
466477
secondaryAllocationIds: props.secondaryAllocationIds,
467478
...props,
468479
});
469-
this.natGatewayId = this.resource.attrNatGatewayId;
480+
this.natGatewayId = FeatureFlags.of(this).isEnabled(cx_api.USE_RESOURCEID_FOR_VPCV2_MIGRATION) ?
481+
this.resource.ref : this.resource.attrNatGatewayId;
482+
483+
this.routerTargetId = FeatureFlags.of(this).isEnabled(cx_api.USE_RESOURCEID_FOR_VPCV2_MIGRATION) ?
484+
this.resource.ref : this.resource.attrNatGatewayId;
470485

471-
this.routerTargetId = this.resource.attrNatGatewayId;
472486
this.node.defaultChild = this.resource;
473-
this.node.addDependency(props.subnet.internetConnectivityEstablished);
487+
this.resource.node.addDependency(props.subnet.internetConnectivityEstablished);
474488
}
475489
}
476490

@@ -809,7 +823,8 @@ export class RouteTable extends Resource implements IRouteTable {
809823
}
810824
this.node.defaultChild = this.resource;
811825

812-
this.routeTableId = this.resource.attrRouteTableId;
826+
this.routeTableId = FeatureFlags.of(this).isEnabled(cx_api.USE_RESOURCEID_FOR_VPCV2_MIGRATION) ?
827+
this.resource.ref : this.resource.attrRouteTableId;
813828
}
814829

815830
/**

packages/@aws-cdk/aws-ec2-alpha/lib/subnet-v2.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Resource, Names, Lazy, Tags, Token, ValidationError, UnscopedValidation
22
import { CfnSubnet, CfnSubnetRouteTableAssociation, INetworkAcl, IRouteTable, ISubnet, NetworkAcl, SubnetNetworkAclAssociation, SubnetType } from 'aws-cdk-lib/aws-ec2';
33
import { Construct, DependencyGroup, IDependable } from 'constructs';
44
import { IVpcV2 } from './vpc-v2-base';
5-
import { CidrBlock, CidrBlockIpv6 } from './util';
5+
import { CidrBlock, CidrBlockIpv6, defaultSubnetName } from './util';
66
import { RouteTable } from './route';
77
import { addConstructMetadata, MethodMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
88

@@ -28,14 +28,14 @@ export class IpCidr implements ICidr {
2828
}
2929

3030
/**
31-
* Name tag constant
31+
* VPC Name tag constant
3232
*/
33-
const NAME_TAG: string = 'Name';
33+
const SUBNETTYPE_TAG = 'aws-cdk:subnet-type';
3434

3535
/**
36-
* VPC Name tag constant
36+
* Subnet Name tag constant
3737
*/
38-
const VPCNAME_TAG: string = 'VpcName';
38+
const SUBNETNAME_TAG = 'aws-cdk:subnet-name';
3939

4040
/**
4141
* Properties to define subnet for VPC.
@@ -71,6 +71,13 @@ export interface SubnetV2Props {
7171
*/
7272
readonly routeTable?: IRouteTable;
7373

74+
/**
75+
* Name of the default RouteTable created by CDK to be used for tagging
76+
*
77+
* @default - default route table name created by CDK as 'DefaultCDKRouteTable'
78+
*/
79+
readonly defaultRouteTableName ?: string;
80+
7481
/**
7582
* The type of Subnet to configure.
7683
*
@@ -307,21 +314,20 @@ export class SubnetV2 extends Resource implements ISubnetV2 {
307314

308315
this._networkAcl = NetworkAcl.fromNetworkAclId(this, 'Acl', subnet.attrNetworkAclAssociationId);
309316

317+
const includeResourceTypes = [CfnSubnet.CFN_RESOURCE_TYPE_NAME];
310318
if (props.subnetName) {
311-
Tags.of(this).add(NAME_TAG, props.subnetName);
312-
}
313-
314-
if (props.vpc.vpcName) {
315-
Tags.of(this).add(VPCNAME_TAG, props.vpc.vpcName);
319+
Tags.of(subnet).add(SUBNETNAME_TAG, props.subnetName);
316320
}
321+
const subnetTypeName = defaultSubnetName(props.subnetType) ?? 'undefined';
322+
Tags.of(subnet).add(SUBNETTYPE_TAG, subnetTypeName, { includeResourceTypes });
317323

318324
if (props.routeTable) {
319325
this._routeTable = props.routeTable;
320326
} else {
321327
// Assigning a default route table
322328
this._routeTable = new RouteTable(this, 'RouteTable', {
323329
vpc: props.vpc,
324-
routeTableName: 'DefaultCDKRouteTable',
330+
routeTableName: props.defaultRouteTableName ?? 'DefaultCDKRouteTable',
325331
});
326332
}
327333

packages/@aws-cdk/aws-ec2-alpha/lib/util.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
/* eslint no-bitwise: ["error", { "allow": ["~", "|", "<<", "&"] }] */
22

3-
import { ISubnet } from 'aws-cdk-lib/aws-ec2';
3+
import { ISubnet, SubnetType } from 'aws-cdk-lib/aws-ec2';
4+
5+
/**
6+
* The default names for every subnet type
7+
*/
8+
export function defaultSubnetName(type: SubnetType) {
9+
switch (type) {
10+
case SubnetType.PUBLIC: return 'Public';
11+
case SubnetType.PRIVATE_WITH_NAT:
12+
case SubnetType.PRIVATE_WITH_EGRESS:
13+
return 'Private';
14+
case SubnetType.PRIVATE_ISOLATED:
15+
return 'Isolated';
16+
}
17+
return undefined;
18+
}
419

520
/**
621
* Return a subnet name from its construct ID

packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { CfnVPC, CfnVPCCidrBlock, DefaultInstanceTenancy, ISubnet, SubnetType } from 'aws-cdk-lib/aws-ec2';
2-
import { Arn, CfnResource, Lazy, Names, Resource, Tags } from 'aws-cdk-lib/core';
2+
import { Arn, CfnResource, FeatureFlags, Lazy, Names, Resource, Tags } from 'aws-cdk-lib/core';
33
import { Construct, DependencyGroup, IDependable } from 'constructs';
44
import { IpamOptions, IIpamPool } from './ipam';
55
import { IVpcV2, VpcV2Base } from './vpc-v2-base';
66
import { ISubnetV2, SubnetV2, SubnetV2Attributes } from './subnet-v2';
7-
import { region_info } from 'aws-cdk-lib';
7+
import { cx_api, region_info } from 'aws-cdk-lib';
88
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
99

1010
/**
@@ -521,7 +521,8 @@ export class VpcV2 extends VpcV2Base {
521521
this.ipv4CidrBlock = vpcOptions.ipv4CidrBlock;
522522
}
523523
this.ipv6CidrBlocks = this.resource.attrIpv6CidrBlocks;
524-
this.vpcId = this.resource.attrVpcId;
524+
this.vpcId = FeatureFlags.of(this).isEnabled(cx_api.USE_RESOURCEID_FOR_VPCV2_MIGRATION) ?
525+
this.resource.ref : this.resource.attrVpcId;
525526
this.vpcArn = Arn.format({
526527
service: 'ec2',
527528
resource: 'vpc',

packages/@aws-cdk/aws-ec2-alpha/test/integ.byoip-ipv6.js.snapshot/manifest.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)