Skip to content

Commit aea72ad

Browse files
author
Elad Ben-Israel
committed
chore: intro "Legacy.uniqueId" instead of the deprecated "node.uniqueId"
The property `node.uniqueId` is used throughout our codebase to generate unique names. We are planning to deprecate this API in constructs 10.x (and CDK 2.0) in favor of a `node.addr` (see aws/constructs#314). In most cases, these generated names cannot be changed because they will incur breaking changes to deployments. So we have to continue to use the "legacy" unique ID in those cases (new cases should use `addr`). To that end, we introduce a utility `Legacy.uniqueId()` which uses the legacy algorithm and the code base was migrated to use it instead of `node.uniqueId` which will go away soon.
1 parent e32ab51 commit aea72ad

File tree

68 files changed

+193
-139
lines changed

Some content is hidden

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

68 files changed

+193
-139
lines changed

packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as iam from '@aws-cdk/aws-iam';
22
import * as lambda from '@aws-cdk/aws-lambda';
3-
import { Duration, Lazy, Stack } from '@aws-cdk/core';
3+
import { Duration, Lazy, Legacy, Stack } from '@aws-cdk/core';
44
import { Construct } from 'constructs';
55
import { CfnAuthorizer } from '../apigateway.generated';
66
import { Authorizer, IAuthorizer } from '../authorizer';
@@ -13,7 +13,7 @@ export interface LambdaAuthorizerProps {
1313
/**
1414
* An optional human friendly name for the authorizer. Note that, this is not the primary identifier of the authorizer.
1515
*
16-
* @default this.node.uniqueId
16+
* @default - the unique construcrt ID
1717
*/
1818
readonly authorizerName?: string;
1919

@@ -97,7 +97,7 @@ abstract class LambdaAuthorizer extends Authorizer implements IAuthorizer {
9797
*/
9898
protected setupPermissions() {
9999
if (!this.role) {
100-
this.handler.addPermission(`${this.node.uniqueId}:Permissions`, {
100+
this.handler.addPermission(`${Legacy.uniqueId(this)}:Permissions`, {
101101
principal: new iam.ServicePrincipal('apigateway.amazonaws.com'),
102102
sourceArn: this.authorizerArn,
103103
});
@@ -168,7 +168,7 @@ export class TokenAuthorizer extends LambdaAuthorizer {
168168

169169
const restApiId = this.lazyRestApiId();
170170
const resource = new CfnAuthorizer(this, 'Resource', {
171-
name: props.authorizerName ?? this.node.uniqueId,
171+
name: props.authorizerName ?? Legacy.uniqueId(this),
172172
restApiId,
173173
type: 'TOKEN',
174174
authorizerUri: lambdaAuthorizerArn(props.handler),
@@ -230,7 +230,7 @@ export class RequestAuthorizer extends LambdaAuthorizer {
230230

231231
const restApiId = this.lazyRestApiId();
232232
const resource = new CfnAuthorizer(this, 'Resource', {
233-
name: props.authorizerName ?? this.node.uniqueId,
233+
name: props.authorizerName ?? Legacy.uniqueId(this),
234234
restApiId,
235235
type: 'REQUEST',
236236
authorizerUri: lambdaAuthorizerArn(props.handler),

packages/@aws-cdk/aws-apigateway/lib/domain-name.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as acm from '@aws-cdk/aws-certificatemanager';
22
import { IBucket } from '@aws-cdk/aws-s3';
3-
import { IResource, Resource, Token } from '@aws-cdk/core';
3+
import { IResource, Legacy, Resource, Token } from '@aws-cdk/core';
44
import { Construct } from 'constructs';
55
import { CfnDomainName } from './apigateway.generated';
66
import { BasePathMapping, BasePathMappingOptions } from './base-path-mapping';
@@ -147,7 +147,7 @@ export class DomainName extends Resource implements IDomainName {
147147
*/
148148
public addBasePathMapping(targetApi: IRestApi, options: BasePathMappingOptions = { }) {
149149
const basePath = options.basePath || '/';
150-
const id = `Map:${basePath}=>${targetApi.node.uniqueId}`;
150+
const id = `Map:${basePath}=>${Legacy.uniqueId(targetApi)}`;
151151
return new BasePathMapping(this, id, {
152152
domainName: this,
153153
restApi: targetApi,

packages/@aws-cdk/aws-apigateway/lib/integrations/lambda.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as iam from '@aws-cdk/aws-iam';
22
import * as lambda from '@aws-cdk/aws-lambda';
3-
import { Lazy, Token } from '@aws-cdk/core';
3+
import { Lazy, Legacy, Token } from '@aws-cdk/core';
44
import { IntegrationConfig, IntegrationOptions } from '../integration';
55
import { Method } from '../method';
66
import { AwsIntegration } from './aws';
@@ -56,7 +56,7 @@ export class LambdaIntegration extends AwsIntegration {
5656
const bindResult = super.bind(method);
5757
const principal = new iam.ServicePrincipal('apigateway.amazonaws.com');
5858

59-
const desc = `${method.api.node.uniqueId}.${method.httpMethod}.${method.resource.path.replace(/\//g, '.')}`;
59+
const desc = `${Legacy.uniqueId(method.api)}.${method.httpMethod}.${method.resource.path.replace(/\//g, '.')}`;
6060

6161
this.handler.addPermission(`ApiPermission.${desc}`, {
6262
principal,

packages/@aws-cdk/aws-apigateway/lib/usage-plan.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Lazy, Resource, Token } from '@aws-cdk/core';
1+
import { Lazy, Legacy, Resource, Token } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
33
import { IApiKey } from './api-key';
44
import { CfnUsagePlan, CfnUsagePlanKey } from './apigateway.generated';
@@ -182,7 +182,7 @@ export class UsagePlan extends Resource {
182182
const prefix = 'UsagePlanKeyResource';
183183

184184
// Postfixing apikey id only from the 2nd child, to keep physicalIds of UsagePlanKey for existing CDK apps unmodifed.
185-
const id = this.node.tryFindChild(prefix) ? `${prefix}:${apiKey.node.uniqueId}` : prefix;
185+
const id = this.node.tryFindChild(prefix) ? `${prefix}:${Legacy.uniqueId(apiKey)}` : prefix;
186186

187187
new CfnUsagePlanKey(this, id, {
188188
keyId: apiKey.keyId,

packages/@aws-cdk/aws-apigateway/lib/vpc-link.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2';
2-
import { IResource, Lazy, Resource } from '@aws-cdk/core';
2+
import { IResource, Lazy, Legacy, Resource } from '@aws-cdk/core';
33
import { Construct } from 'constructs';
44
import { CfnVpcLink } from './apigateway.generated';
55

@@ -66,7 +66,7 @@ export class VpcLink extends Resource implements IVpcLink {
6666
constructor(scope: Construct, id: string, props: VpcLinkProps = {}) {
6767
super(scope, id, {
6868
physicalName: props.vpcLinkName ||
69-
Lazy.stringValue({ produce: () => this.node.uniqueId }),
69+
Lazy.stringValue({ produce: () => Legacy.uniqueId(this.node) }),
7070
});
7171

7272
const cfnResource = new CfnVpcLink(this, 'Resource', {

packages/@aws-cdk/aws-apigatewayv2/lib/http/integrations/lambda.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ServicePrincipal } from '@aws-cdk/aws-iam';
22
import { IFunction } from '@aws-cdk/aws-lambda';
3-
import { Stack } from '@aws-cdk/core';
3+
import { Legacy, Stack } from '@aws-cdk/core';
44
import { HttpIntegrationType, HttpRouteIntegrationBindOptions, HttpRouteIntegrationConfig, IHttpRouteIntegration, PayloadFormatVersion } from '../integration';
55

66
/**
@@ -30,7 +30,7 @@ export class LambdaProxyIntegration implements IHttpRouteIntegration {
3030

3131
public bind(options: HttpRouteIntegrationBindOptions): HttpRouteIntegrationConfig {
3232
const route = options.route;
33-
this.props.handler.addPermission(`${route.node.uniqueId}-Permission`, {
33+
this.props.handler.addPermission(`${Legacy.uniqueId(route)}-Permission`, {
3434
scope: options.scope,
3535
principal: new ServicePrincipal('apigateway.amazonaws.com'),
3636
sourceArn: Stack.of(route).formatArn({

packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class StepScalingAction extends cdk.Construct {
8282
// properties, or the ScalingTargetId property, but not both.
8383
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-applicationautoscaling-scalingpolicy.html
8484
const resource = new CfnScalingPolicy(this, 'Resource', {
85-
policyName: props.policyName || this.node.uniqueId,
85+
policyName: props.policyName || cdk.Legacy.uniqueId(this),
8686
policyType: 'StepScaling',
8787
scalingTargetId: props.scalingTarget.scalableTargetId,
8888
stepScalingPolicyConfiguration: {

packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class TargetTrackingScalingPolicy extends cdk.Construct {
133133
super(scope, id);
134134

135135
const resource = new CfnScalingPolicy(this, 'Resource', {
136-
policyName: props.policyName || this.node.uniqueId,
136+
policyName: props.policyName || cdk.Legacy.uniqueId(this),
137137
policyType: 'TargetTrackingScaling',
138138
scalingTargetId: props.scalingTarget.scalableTargetId,
139139
targetTrackingScalingPolicyConfiguration: {

packages/@aws-cdk/aws-appmesh/lib/mesh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class Mesh extends MeshBase {
170170

171171
constructor(scope: Construct, id: string, props: MeshProps = {}) {
172172
super(scope, id, {
173-
physicalName: props.meshName || cdk.Lazy.stringValue({ produce: () => this.node.uniqueId }),
173+
physicalName: props.meshName || cdk.Lazy.stringValue({ produce: () => cdk.Legacy.uniqueId(this) }),
174174
});
175175

176176
const mesh = new CfnMesh(this, 'Resource', {

packages/@aws-cdk/aws-appmesh/lib/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class Route extends cdk.Resource implements IRoute {
145145

146146
constructor(scope: Construct, id: string, props: RouteProps) {
147147
super(scope, id, {
148-
physicalName: props.routeName || cdk.Lazy.stringValue({ produce: () => this.node.uniqueId }),
148+
physicalName: props.routeName || cdk.Lazy.stringValue({ produce: () => cdk.Legacy.uniqueId(this) }),
149149
});
150150

151151
this.virtualRouter = props.virtualRouter;

packages/@aws-cdk/aws-appmesh/lib/virtual-node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class VirtualNode extends VirtualNodeBase {
252252

253253
constructor(scope: Construct, id: string, props: VirtualNodeProps) {
254254
super(scope, id, {
255-
physicalName: props.virtualNodeName || cdk.Lazy.stringValue({ produce: () => this.node.uniqueId }),
255+
physicalName: props.virtualNodeName || cdk.Lazy.stringValue({ produce: () => cdk.Legacy.uniqueId(this) }),
256256
});
257257

258258
this.mesh = props.mesh;

packages/@aws-cdk/aws-appmesh/lib/virtual-router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class VirtualRouter extends VirtualRouterBase {
145145

146146
constructor(scope: Construct, id: string, props: VirtualRouterProps) {
147147
super(scope, id, {
148-
physicalName: props.virtualRouterName || cdk.Lazy.stringValue({ produce: () => this.node.uniqueId }),
148+
physicalName: props.virtualRouterName || cdk.Lazy.stringValue({ produce: () => cdk.Legacy.uniqueId(this) }),
149149
});
150150

151151
this.mesh = props.mesh;

packages/@aws-cdk/aws-appmesh/lib/virtual-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class VirtualService extends cdk.Resource implements IVirtualService {
106106

107107
constructor(scope: Construct, id: string, props: VirtualServiceProps) {
108108
super(scope, id, {
109-
physicalName: props.virtualServiceName || cdk.Lazy.stringValue({ produce: () => this.node.uniqueId }),
109+
physicalName: props.virtualServiceName || cdk.Lazy.stringValue({ produce: () => cdk.Legacy.uniqueId(this) }),
110110
});
111111

112112
if (props.virtualNode && props.virtualRouter) {

packages/@aws-cdk/aws-backup/lib/vault.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as iam from '@aws-cdk/aws-iam';
22
import * as kms from '@aws-cdk/aws-kms';
33
import * as sns from '@aws-cdk/aws-sns';
4-
import { IResource, RemovalPolicy, Resource } from '@aws-cdk/core';
4+
import { IResource, Legacy, RemovalPolicy, Resource } from '@aws-cdk/core';
55
import { Construct } from 'constructs';
66
import { CfnBackupVault } from './backup.generated';
77

@@ -161,7 +161,7 @@ export class BackupVault extends Resource implements IBackupVault {
161161

162162
private uniqueVaultName() {
163163
// Max length of 50 chars, get the last 50 chars
164-
const id = this.node.uniqueId;
164+
const id = Legacy.uniqueId(this);
165165
return id.substring(Math.max(id.length - 50, 0), id.length);
166166
}
167167
}

packages/@aws-cdk/aws-batch/test/compute-environment.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { throws } from 'assert';
12
import { expect, haveResource, haveResourceLike, ResourcePart } from '@aws-cdk/assert';
23
import '@aws-cdk/assert/jest';
34
import * as ec2 from '@aws-cdk/aws-ec2';
45
import * as ecs from '@aws-cdk/aws-ecs';
56
import * as iam from '@aws-cdk/aws-iam';
67
import * as cdk from '@aws-cdk/core';
7-
import { throws } from 'assert';
88
import * as batch from '../lib';
99

1010
describe('Batch Compute Evironment', () => {
@@ -240,10 +240,10 @@ describe('Batch Compute Evironment', () => {
240240
],
241241
Subnets: [
242242
{
243-
Ref: `${vpc.node.uniqueId}PrivateSubnet1Subnet865FB50A`,
243+
Ref: `${cdk.Legacy.uniqueId(vpc)}PrivateSubnet1Subnet865FB50A`,
244244
},
245245
{
246-
Ref: `${vpc.node.uniqueId}PrivateSubnet2Subnet23D3396F`,
246+
Ref: `${cdk.Legacy.uniqueId(vpc)}PrivateSubnet2Subnet23D3396F`,
247247
},
248248
],
249249
Tags: {

packages/@aws-cdk/aws-cloudformation/test/test.nested-stack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'path';
33
import { expect, haveResource, matchTemplate, SynthUtils } from '@aws-cdk/assert';
44
import * as s3_assets from '@aws-cdk/aws-s3-assets';
55
import * as sns from '@aws-cdk/aws-sns';
6-
import { App, CfnParameter, CfnResource, Construct, ContextProvider, Stack } from '@aws-cdk/core';
6+
import { App, CfnParameter, CfnResource, Construct, ContextProvider, Legacy, Stack } from '@aws-cdk/core';
77
import { Test } from 'nodeunit';
88
import { NestedStack } from '../lib/nested-stack';
99

@@ -63,7 +63,7 @@ export = {
6363
const assembly = app.synth();
6464

6565
// THEN
66-
const template = JSON.parse(fs.readFileSync(path.join(assembly.directory, `${nested.node.uniqueId}.nested.template.json`), 'utf-8'));
66+
const template = JSON.parse(fs.readFileSync(path.join(assembly.directory, `${Legacy.uniqueId(nested)}.nested.template.json`), 'utf-8'));
6767
test.deepEqual(template, {
6868
Resources: {
6969
ResourceInNestedStack: {

packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class S3BucketOrigin extends cloudfront.OriginBase {
7474
const bucketStack = cdk.Stack.of(this.bucket);
7575
const bucketInDifferentStack = bucketStack !== cdk.Stack.of(scope);
7676
const oaiScope = bucketInDifferentStack ? bucketStack : scope;
77-
const oaiId = bucketInDifferentStack ? `${scope.node.uniqueId}S3Origin` : 'S3Origin';
77+
const oaiId = bucketInDifferentStack ? `${cdk.Legacy.uniqueId(scope)}S3Origin` : 'S3Origin';
7878

7979
this.originAccessIdentity = new cloudfront.OriginAccessIdentity(oaiScope, oaiId, {
8080
comment: `Identity for ${options.originId}`,

packages/@aws-cdk/aws-cloudfront/lib/cache-policy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Duration, Resource, Token } from '@aws-cdk/core';
1+
import { Duration, Legacy, Resource, Token } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
33
import { CfnCachePolicy } from './cloudfront.generated';
44

@@ -128,7 +128,7 @@ export class CachePolicy extends Resource implements ICachePolicy {
128128
physicalName: props.cachePolicyName,
129129
});
130130

131-
const cachePolicyName = props.cachePolicyName ?? this.node.uniqueId;
131+
const cachePolicyName = props.cachePolicyName ?? Legacy.uniqueId(this);
132132
if (!Token.isUnresolved(cachePolicyName) && !cachePolicyName.match(/^[\w-]+$/i)) {
133133
throw new Error(`'cachePolicyName' can only include '-', '_', and alphanumeric characters, got: '${props.cachePolicyName}'`);
134134
}

packages/@aws-cdk/aws-cloudfront/lib/distribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as acm from '@aws-cdk/aws-certificatemanager';
22
import * as lambda from '@aws-cdk/aws-lambda';
33
import * as s3 from '@aws-cdk/aws-s3';
4-
import { IResource, Lazy, Resource, Stack, Token, Duration } from '@aws-cdk/core';
4+
import { IResource, Lazy, Resource, Stack, Token, Duration, Legacy } from '@aws-cdk/core';
55
import { Construct, Node } from 'constructs';
66
import { ICachePolicy } from './cache-policy';
77
import { CfnDistribution } from './cloudfront.generated';
@@ -322,7 +322,7 @@ export class Distribution extends Resource implements IDistribution {
322322
} else {
323323
const originIndex = this.boundOrigins.length + 1;
324324
const scope = new CoreConstruct(this, `Origin${originIndex}`);
325-
const originId = Node.of(scope).uniqueId;
325+
const originId = Legacy.uniqueId(scope);
326326
const originBindConfig = origin.bind(scope, { originId });
327327
if (!originBindConfig.failoverConfig) {
328328
this.boundOrigins.push({ origin, originId, ...originBindConfig });
@@ -331,7 +331,7 @@ export class Distribution extends Resource implements IDistribution {
331331
throw new Error('An Origin cannot use an Origin with its own failover configuration as its fallback origin!');
332332
}
333333
const groupIndex = this.originGroups.length + 1;
334-
const originGroupId = Node.of(new CoreConstruct(this, `OriginGroup${groupIndex}`)).uniqueId;
334+
const originGroupId = Legacy.uniqueId(new CoreConstruct(this, `OriginGroup${groupIndex}`));
335335
this.boundOrigins.push({ origin, originId, originGroupId, ...originBindConfig });
336336

337337
const failoverOriginId = this.addOrigin(originBindConfig.failoverConfig.failoverOrigin, true);

packages/@aws-cdk/aws-cloudfront/lib/origin-request-policy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Resource, Token } from '@aws-cdk/core';
1+
import { Legacy, Resource, Token } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
33
import { CfnOriginRequestPolicy } from './cloudfront.generated';
44

@@ -91,7 +91,7 @@ export class OriginRequestPolicy extends Resource implements IOriginRequestPolic
9191
physicalName: props.originRequestPolicyName,
9292
});
9393

94-
const originRequestPolicyName = props.originRequestPolicyName ?? this.node.uniqueId;
94+
const originRequestPolicyName = props.originRequestPolicyName ?? Legacy.uniqueId(this);
9595
if (!Token.isUnresolved(originRequestPolicyName) && !originRequestPolicyName.match(/^[\w-]+$/i)) {
9696
throw new Error(`'originRequestPolicyName' can only include '-', '_', and alphanumeric characters, got: '${props.originRequestPolicyName}'`);
9797
}

packages/@aws-cdk/aws-cloudwatch/lib/composite-alarm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Lazy, Stack } from '@aws-cdk/core';
1+
import { Lazy, Legacy, Stack } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
33
import { AlarmBase, IAlarm, IAlarmRule } from './alarm-base';
44
import { CfnCompositeAlarm } from './cloudwatch.generated';
@@ -120,7 +120,7 @@ export class CompositeAlarm extends AlarmBase {
120120
}
121121

122122
private generateUniqueId(): string {
123-
const name = this.node.uniqueId;
123+
const name = Legacy.uniqueId(this);
124124
if (name.length > 240) {
125125
return name.substring(0, 120) + name.substring(name.length - 120);
126126
}

packages/@aws-cdk/aws-codebuild/lib/project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as iam from '@aws-cdk/aws-iam';
77
import * as kms from '@aws-cdk/aws-kms';
88
import * as s3 from '@aws-cdk/aws-s3';
99
import * as secretsmanager from '@aws-cdk/aws-secretsmanager';
10-
import { Aws, Duration, IResource, Lazy, PhysicalName, Resource, Stack } from '@aws-cdk/core';
10+
import { Aws, Duration, IResource, Lazy, Legacy, PhysicalName, Resource, Stack } from '@aws-cdk/core';
1111
import { Construct } from 'constructs';
1212
import { IArtifacts } from './artifacts';
1313
import { BuildSpec } from './build-spec';
@@ -1019,7 +1019,7 @@ export class Project extends ProjectBase {
10191019
} else {
10201020
const securityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', {
10211021
vpc: props.vpc,
1022-
description: 'Automatic generated security group for CodeBuild ' + this.node.uniqueId,
1022+
description: 'Automatic generated security group for CodeBuild ' + Legacy.uniqueId(this),
10231023
allowAllOutbound: props.allowAllOutbound,
10241024
});
10251025
securityGroups = [securityGroup];

packages/@aws-cdk/aws-codedeploy/lib/lambda/custom-deployment-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Duration, Resource } from '@aws-cdk/core';
1+
import { Duration, Legacy, Resource } from '@aws-cdk/core';
22
import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId } from '@aws-cdk/custom-resources';
33
import { Construct } from 'constructs';
44
import { arnForDeploymentConfig } from '../utils';
@@ -101,7 +101,7 @@ export class CustomLambdaDeploymentConfig extends Resource implements ILambdaDep
101101
// Unless the user provides an explicit name
102102
this.deploymentConfigName = props.deploymentConfigName !== undefined
103103
? props.deploymentConfigName
104-
: `${this.node.uniqueId}.Lambda${props.type}${props.percentage}Percent${props.type === CustomLambdaDeploymentConfigType.LINEAR
104+
: `${Legacy.uniqueId(this)}.Lambda${props.type}${props.percentage}Percent${props.type === CustomLambdaDeploymentConfigType.LINEAR
105105
? 'Every'
106106
: ''}${props.interval.toMinutes()}Minutes`;
107107
this.deploymentConfigArn = arnForDeploymentConfig(this.deploymentConfigName);

packages/@aws-cdk/aws-codeguruprofiler/lib/profiling-group.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Grant, IGrantable } from '@aws-cdk/aws-iam';
2-
import { IResource, Lazy, Resource, Stack } from '@aws-cdk/core';
2+
import { IResource, Lazy, Legacy, Resource, Stack } from '@aws-cdk/core';
33
import { Construct } from 'constructs';
44
import { CfnProfilingGroup } from './codeguruprofiler.generated';
55

@@ -195,7 +195,7 @@ export class ProfilingGroup extends ProfilingGroupBase {
195195
}
196196

197197
private generateUniqueId(): string {
198-
const name = this.node.uniqueId;
198+
const name = Legacy.uniqueId(this);
199199
if (name.length > 240) {
200200
return name.substring(0, 120) + name.substring(name.length - 120);
201201
}

packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ abstract class CloudFormationDeployAction extends CloudFormationAction {
270270
// pass role is not allowed for cross-account access - so,
271271
// create the deployment Role in the other account!
272272
this._deploymentRole = new iam.Role(roleStack,
273-
`${stage.pipeline.node.uniqueId}-${stage.stageName}-${this.actionProperties.actionName}-DeploymentRole`, {
273+
`${cdk.Legacy.uniqueId(stage.pipeline)}-${stage.stageName}-${this.actionProperties.actionName}-DeploymentRole`, {
274274
assumedBy: new iam.ServicePrincipal('cloudformation.amazonaws.com'),
275275
roleName: cdk.PhysicalName.GENERATE_IF_NEEDED,
276276
});

0 commit comments

Comments
 (0)