Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore(aws-cdk-lib): enable project references #32970

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/@aws-cdk/aws-ec2-alpha/lib/subnet-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,13 @@ export interface SubnetV2Attributes {

}

const subnetTypeMap = {
type DeprecatedSubnetType = 'Deprecated_Isolated' | 'Deprecated_Private';
const subnetTypeMap: { [key in SubnetType | DeprecatedSubnetType]: (vpc: IVpcV2, subnet: SubnetV2) => void } = {
[SubnetType.PRIVATE_ISOLATED]: (vpc: IVpcV2, subnet: SubnetV2) => vpc.isolatedSubnets.push(subnet),
[SubnetType.PUBLIC]: (vpc: IVpcV2, subnet: SubnetV2) => vpc.publicSubnets.push(subnet),
[SubnetType.PRIVATE_WITH_EGRESS]: (vpc: IVpcV2, subnet: SubnetV2) => vpc.privateSubnets.push(subnet),
[SubnetType.ISOLATED]: (vpc: IVpcV2, subnet: SubnetV2) => vpc.isolatedSubnets.push(subnet),
[SubnetType.PRIVATE]: (vpc: IVpcV2, subnet: SubnetV2) => vpc.privateSubnets.push(subnet),
['Deprecated_Isolated']: (vpc: IVpcV2, subnet: SubnetV2) => vpc.isolatedSubnets.push(subnet),
['Deprecated_Private']: (vpc: IVpcV2, subnet: SubnetV2) => vpc.privateSubnets.push(subnet),
[SubnetType.PRIVATE_WITH_NAT]: (vpc: IVpcV2, subnet: SubnetV2) => vpc.privateSubnets.push(subnet),
};

Expand Down
15 changes: 8 additions & 7 deletions packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,17 +636,18 @@ export abstract class VpcV2Base extends Resource implements IVpcV2 {
return subnets;
}

private selectSubnetObjectsByType(subnetType: SubnetType) {
const allSubnets = {
private selectSubnetObjectsByType(subnetType: SubnetType): ISubnet[] {
type DeprecatedSubnetType = 'Deprecated_Isolated' | 'Deprecated_Private';
const allSubnets: { [key in SubnetType | DeprecatedSubnetType]?: ISubnet[] } = {
[SubnetType.PRIVATE_ISOLATED]: this.isolatedSubnets,
[SubnetType.ISOLATED]: this.isolatedSubnets,
['Deprecated_Isolated']: this.isolatedSubnets,
[SubnetType.PRIVATE_WITH_NAT]: this.privateSubnets,
[SubnetType.PRIVATE_WITH_EGRESS]: this.privateSubnets,
[SubnetType.PRIVATE]: this.privateSubnets,
['Deprecated_Private']: this.privateSubnets,
[SubnetType.PUBLIC]: this.publicSubnets,
};

const subnets = allSubnets[subnetType];
const subnets = allSubnets[subnetType]!;

// Force merge conflict here with https://github.com/aws/aws-cdk/pull/4089
// see ImportedVpc
Expand All @@ -668,13 +669,13 @@ export abstract class VpcV2Base extends Resource implements IVpcV2 {
private reifySelectionDefaults(placement: SubnetSelection): SubnetSelection {

// TODO: throw error as new VpcV2 cannot support subnetName or subnetGroupName anymore
if (placement.subnetName !== undefined) {
if ('subnetName' in placement && placement.subnetName !== undefined) {
if (placement.subnetGroupName !== undefined) {
throw new Error('Please use only \'subnetGroupName\' (\'subnetName\' is deprecated and has the same behavior)');
} else {
Annotations.of(this).addWarningV2('@aws-cdk/aws-ec2:subnetNameDeprecated', 'Usage of \'subnetName\' in SubnetSelection is deprecated, use \'subnetGroupName\' instead');
}
placement = { ...placement, subnetGroupName: placement.subnetName };
placement = { ...placement, subnetGroupName: placement.subnetName as string };
}

const exclusiveSelections: Array<keyof SubnetSelection> = ['subnets', 'subnetType', 'subnetGroupName'];
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ export class VpcV2 extends VpcV2Base {
if (props.subnets) {
for (const subnet of props.subnets) {
if (subnet.subnetType === SubnetType.PRIVATE_WITH_EGRESS || subnet.subnetType === SubnetType.PRIVATE_WITH_NAT ||
subnet.subnetType === SubnetType.PRIVATE) {
subnet.subnetType as string === 'Deprecated_Private') {
this.privateSubnets.push(SubnetV2.fromSubnetV2Attributes(scope, subnet.subnetName?? 'ImportedPrivateSubnet', subnet));
} else if (subnet.subnetType === SubnetType.PUBLIC) {
this.publicSubnets.push(SubnetV2.fromSubnetV2Attributes(scope, subnet.subnetName?? 'ImportedPublicSubnet', subnet));
} else if (subnet.subnetType === SubnetType.ISOLATED || subnet.subnetType === SubnetType.PRIVATE_ISOLATED) {
} else if (subnet.subnetType as string === 'Deprecated_Isolated' || subnet.subnetType === SubnetType.PRIVATE_ISOLATED) {
this.isolatedSubnets.push(SubnetV2.fromSubnetV2Attributes(scope, subnet.subnetName?? 'ImportedIsolatedSubnet', subnet));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TestStack extends cdk.Stack {
const metric = new cloudwatch.Metric({
namespace: 'MyNamespace',
metricName: 'MyMetric',
dimensions: { MyDimension: 'MyDimensionValue' },
dimensionsMap: { MyDimension: 'MyDimensionValue' },
});
const alarm = new cloudwatch.Alarm(this, 'MyAlarm', {
metric: metric,
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-iot-alpha/lib/logging.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resource, Stack, IResource } from 'aws-cdk-lib/core';
import { Resource, Stack, IResource, ArnFormat } from 'aws-cdk-lib/core';
import { Construct } from 'constructs';
import * as iot from 'aws-cdk-lib/aws-iot';
import * as iam from 'aws-cdk-lib/aws-iam';
Expand Down Expand Up @@ -119,7 +119,7 @@ export class Logging extends Resource implements ILogging {
Stack.of(this).formatArn({
service: 'logs',
resource: 'log-group',
sep: ':',
arnFormat: ArnFormat.COLON_RESOURCE_NAME,
resourceName: 'AWSIotLogsV2:*',
}),
],
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-lambda-go-alpha/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ test('Local bundling', () => {

expect(bundler.local).toBeDefined();

const tryBundle = bundler.local?.tryBundle('/outdir', { image: Runtime.GO_1_X.bundlingDockerImage });
const tryBundle = bundler.local?.tryBundle('/outdir', { image: Runtime.GO_1_X.bundlingImage });
expect(tryBundle).toBe(true);

expect(spawnSyncMock).toHaveBeenCalledWith(
Expand All @@ -217,7 +217,7 @@ test('Incorrect go version', () => {
architecture: Architecture.X86_64,
});

const tryBundle = bundler.local?.tryBundle('/outdir', { image: Runtime.GO_1_X.bundlingDockerImage });
const tryBundle = bundler.local?.tryBundle('/outdir', { image: Runtime.GO_1_X.bundlingImage });

expect(tryBundle).toBe(false);
});
Expand Down
11 changes: 5 additions & 6 deletions packages/@aws-cdk/aws-lambda-python-alpha/test/function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ jest.mock('../lib/bundling', () => {
throw new Error('unexpected asset hash type');
})();

return {
isInline: false,
bind: () => ({
return new class extends lambda.Code {
public readonly isInline: boolean = false;
public bind = () => ({
s3Location: {
bucketName: 'mock-bucket-name',
objectKey: mockObjectKey,
},
}),
bindToResource: () => { return; },
};
});
}();
}),
hasDependencies: jest.fn().mockReturnValue(false),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-sagemaker-alpha/lib/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class EndpointInstanceProductionVariant implements IEndpointInstanceProductionVa
return new cloudwatch.Metric({
namespace,
metricName,
dimensions: {
dimensionsMap: {
EndpointName: this.endpoint.endpointName,
VariantName: this.variantName,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-sagemaker-alpha/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ abstract class ModelBase extends cdk.Resource implements IModel {
return;
}

this.role.addToPolicy(statement);
this.role.addToPrincipalPolicy(statement);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"packageName": "awscdk"
}
},
"projectReferences": false,
"projectReferences": true,
"metadata": {
"jsii": {
"rosetta": {
Expand Down
7 changes: 0 additions & 7 deletions tools/@aws-cdk/pkglint/lib/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,13 +645,6 @@ export class JSIIProjectReferences extends ValidationRule {
if (!isJSII(pkg)) {
return;
}

expectJSON(
this.name,
pkg,
'jsii.projectReferences',
pkg.json.name !== 'aws-cdk-lib',
);
}
}

Expand Down
Loading