Skip to content

Commit 1dfd24c

Browse files
authored
Merge branch 'master' into expires
2 parents c409d93 + 5f36f6b commit 1dfd24c

File tree

89 files changed

+2201
-275
lines changed

Some content is hidden

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

89 files changed

+2201
-275
lines changed

package.json

+12
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@
6969
"@aws-cdk/core/minimatch/**",
7070
"@aws-cdk/cx-api/semver",
7171
"@aws-cdk/cx-api/semver/**",
72+
"aws-cdk-lib/case",
73+
"aws-cdk-lib/case/**",
74+
"aws-cdk-lib/fs-extra",
75+
"aws-cdk-lib/fs-extra/**",
76+
"aws-cdk-lib/jsonschema",
77+
"aws-cdk-lib/jsonschema/**",
78+
"aws-cdk-lib/minimatch",
79+
"aws-cdk-lib/minimatch/**",
80+
"aws-cdk-lib/semver",
81+
"aws-cdk-lib/semver/**",
82+
"aws-cdk-lib/yaml",
83+
"aws-cdk-lib/yaml/**",
7284
"monocdk-experiment/case",
7385
"monocdk-experiment/case/**",
7486
"monocdk-experiment/fs-extra",

packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as iam from '@aws-cdk/aws-iam';
66
import * as sns from '@aws-cdk/aws-sns';
77

88
import {
9-
CfnAutoScalingRollingUpdate, Construct, Duration, Fn, IResource, Lazy, PhysicalName, Resource, Stack,
9+
Annotations, CfnAutoScalingRollingUpdate, Construct, Duration, Fn, IResource, Lazy, PhysicalName, Resource, Stack,
1010
Tokenization, withResolved, Tags,
1111
} from '@aws-cdk/core';
1212
import { CfnAutoScalingGroup, CfnAutoScalingGroupProps, CfnLaunchConfiguration } from './autoscaling.generated';
@@ -659,7 +659,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
659659
});
660660

661661
if (desiredCapacity !== undefined) {
662-
this.node.addWarning('desiredCapacity has been configured. Be aware this will reset the size of your AutoScalingGroup on every deployment. See https://github.com/aws/aws-cdk/issues/5215');
662+
Annotations.of(this).addWarning('desiredCapacity has been configured. Be aware this will reset the size of your AutoScalingGroup on every deployment. See https://github.com/aws/aws-cdk/issues/5215');
663663
}
664664

665665
this.maxInstanceLifetime = props.maxInstanceLifetime;
@@ -1259,7 +1259,7 @@ function synthesizeBlockDeviceMappings(construct: Construct, blockDevices: Block
12591259
throw new Error('iops property is required with volumeType: EbsDeviceVolumeType.IO1');
12601260
}
12611261
} else if (volumeType !== EbsDeviceVolumeType.IO1) {
1262-
construct.node.addWarning('iops will be ignored without volumeType: EbsDeviceVolumeType.IO1');
1262+
Annotations.of(construct).addWarning('iops will be ignored without volumeType: EbsDeviceVolumeType.IO1');
12631263
}
12641264
}
12651265

packages/@aws-cdk/aws-cognito/test/integ.user-pool-domain-cfdist.expected.json

+9-11
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@
7878
"InstallLatestAwsSdk": true
7979
},
8080
"UpdateReplacePolicy": "Delete",
81-
"DeletionPolicy": "Delete"
81+
"DeletionPolicy": "Delete",
82+
"DependsOn": [
83+
"UserPoolDomainCloudFrontDomainNameCustomResourcePolicy7DE54188"
84+
]
8285
},
8386
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2": {
8487
"Type": "AWS::IAM::Role",
@@ -111,25 +114,21 @@
111114
]
112115
}
113116
},
114-
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleDefaultPolicyD28E1A5E": {
117+
"UserPoolDomainCloudFrontDomainNameCustomResourcePolicy7DE54188": {
115118
"Type": "AWS::IAM::Policy",
116119
"Properties": {
117120
"PolicyDocument": {
118121
"Statement": [
119122
{
120-
"Action": "cognito-idp:DescribeUserPoolDomain",
121-
"Effect": "Allow",
123+
"Action":"cognito-idp:DescribeUserPoolDomain",
124+
"Effect":"Allow",
122125
"Resource": "*"
123126
}
124127
],
125128
"Version": "2012-10-17"
126129
},
127-
"PolicyName": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleDefaultPolicyD28E1A5E",
128-
"Roles": [
129-
{
130-
"Ref": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
131-
}
132-
]
130+
"PolicyName": "UserPoolDomainCloudFrontDomainNameCustomResourcePolicy7DE54188",
131+
"Roles": [{"Ref":"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"}]
133132
}
134133
},
135134
"AWS679f53fac002430cb0da5b7982bd22872D164C4C": {
@@ -184,7 +183,6 @@
184183
"Timeout": 120
185184
},
186185
"DependsOn": [
187-
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleDefaultPolicyD28E1A5E",
188186
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
189187
]
190188
}

packages/@aws-cdk/aws-dynamodb-global/lib/aws-dynamodb-global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class GlobalTable extends cdk.Construct {
4040
constructor(scope: cdk.Construct, id: string, props: GlobalTableProps) {
4141
super(scope, id);
4242

43-
this.node.addWarning('The @aws-cdk/aws-dynamodb-global module has been deprecated in favor of @aws-cdk/aws-dynamodb.Table.replicationRegions');
43+
cdk.Annotations.of(this).addWarning('The @aws-cdk/aws-dynamodb-global module has been deprecated in favor of @aws-cdk/aws-dynamodb.Table.replicationRegions');
4444

4545
this._regionalTables = [];
4646

packages/@aws-cdk/aws-ec2/lib/cfn-init-elements.ts

+4
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ export abstract class InitFile extends InitElement {
432432
source: asset.httpUrl,
433433
}),
434434
authentication: standardS3Auth(bindOptions.instanceRole, asset.s3BucketName),
435+
assetHash: asset.assetHash,
435436
};
436437
}
437438
}(targetFileName, options);
@@ -449,6 +450,7 @@ export abstract class InitFile extends InitElement {
449450
source: asset.httpUrl,
450451
}),
451452
authentication: standardS3Auth(bindOptions.instanceRole, asset.s3BucketName),
453+
assetHash: asset.assetHash,
452454
};
453455
}
454456
}(targetFileName, options);
@@ -899,6 +901,7 @@ export abstract class InitSource extends InitElement {
899901
return {
900902
config: { [this.targetDirectory]: asset.httpUrl },
901903
authentication: standardS3Auth(bindOptions.instanceRole, asset.s3BucketName),
904+
assetHash: asset.assetHash,
902905
};
903906
}
904907
}(targetDirectory, options.serviceRestartHandles);
@@ -915,6 +918,7 @@ export abstract class InitSource extends InitElement {
915918
return {
916919
config: { [this.targetDirectory]: asset.httpUrl },
917920
authentication: standardS3Auth(bindOptions.instanceRole, asset.s3BucketName),
921+
assetHash: asset.assetHash,
918922
};
919923
}
920924
}(targetDirectory, options.serviceRestartHandles);

packages/@aws-cdk/aws-ec2/lib/cfn-init.ts

+19-5
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ export class CloudFormationInit {
9797
// Note: This will not reflect mutations made after attaching.
9898
const bindResult = this.bind(attachedResource.stack, attachOptions);
9999
attachedResource.addMetadata('AWS::CloudFormation::Init', bindResult.configData);
100-
const fingerprint = contentHash(JSON.stringify(bindResult.configData)).substr(0, 16);
100+
101+
// Need to resolve the various tokens from assets in the config,
102+
// as well as include any asset hashes provided so the fingerprint is accurate.
103+
const resolvedConfig = attachedResource.stack.resolve(bindResult.configData);
104+
const fingerprintInput = { config: resolvedConfig, assetHash: bindResult.assetHash };
105+
const fingerprint = contentHash(JSON.stringify(fingerprintInput)).substr(0, 16);
101106

102107
attachOptions.instanceRole.addToPolicy(new iam.PolicyStatement({
103108
actions: ['cloudformation:DescribeStackResource', 'cloudformation:SignalResource'],
@@ -140,7 +145,7 @@ export class CloudFormationInit {
140145
}
141146
}
142147

143-
private bind(scope: Construct, options: AttachInitOptions): { configData: any, authData: any } {
148+
private bind(scope: Construct, options: AttachInitOptions): { configData: any, authData: any, assetHash?: any } {
144149
const nonEmptyConfigs = mapValues(this._configs, c => c.isEmpty() ? undefined : c);
145150

146151
const configNameToBindResult = mapValues(nonEmptyConfigs, c => c._bind(scope, options));
@@ -151,6 +156,7 @@ export class CloudFormationInit {
151156
...mapValues(configNameToBindResult, c => c.config),
152157
},
153158
authData: Object.values(configNameToBindResult).map(c => c.authentication).reduce(deepMerge, undefined),
159+
assetHash: combineAssetHashesOrUndefined(Object.values(configNameToBindResult).map(c => c.assetHash)),
154160
};
155161
}
156162

@@ -201,9 +207,9 @@ export class InitConfig {
201207
// Must be last!
202208
const servicesConfig = this.bindForType(InitElementType.SERVICE, bindOptions);
203209

204-
const authentication = [packageConfig, groupsConfig, usersConfig, sourcesConfig, filesConfig, commandsConfig, servicesConfig]
205-
.map(c => c?.authentication)
206-
.reduce(deepMerge, undefined);
210+
const allConfig = [packageConfig, groupsConfig, usersConfig, sourcesConfig, filesConfig, commandsConfig, servicesConfig];
211+
const authentication = allConfig.map(c => c?.authentication).reduce(deepMerge, undefined);
212+
const assetHash = combineAssetHashesOrUndefined(allConfig.map(c => c?.assetHash));
207213

208214
return {
209215
config: {
@@ -216,6 +222,7 @@ export class InitConfig {
216222
services: servicesConfig?.config,
217223
},
218224
authentication,
225+
assetHash,
219226
};
220227
}
221228

@@ -228,6 +235,7 @@ export class InitConfig {
228235
return {
229236
config: bindResults.map(r => r.config).reduce(deepMerge, undefined) ?? {},
230237
authentication: bindResults.map(r => r.authentication).reduce(deepMerge, undefined),
238+
assetHash: combineAssetHashesOrUndefined(bindResults.map(r => r.assetHash)),
231239
};
232240
}
233241

@@ -310,6 +318,12 @@ function mapValues<A, B>(xs: Record<string, A>, fn: (x: A) => B | undefined): Re
310318
return ret;
311319
}
312320

321+
// Combines all input asset hashes into one, or if no hashes are present, returns undefined.
322+
function combineAssetHashesOrUndefined(hashes: (string | undefined)[]): string | undefined {
323+
const hashArray = hashes.filter((x): x is string => x !== undefined);
324+
return hashArray.length > 0 ? hashArray.join('') : undefined;
325+
}
326+
313327
function contentHash(content: string) {
314328
return crypto.createHash('sha256').update(content).digest('hex');
315329
}

packages/@aws-cdk/aws-ec2/lib/instance.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as crypto from 'crypto';
22
import * as iam from '@aws-cdk/aws-iam';
33

4-
import { Construct, Duration, Fn, IResource, Lazy, Resource, Stack, Tags } from '@aws-cdk/core';
4+
import { Annotations, Construct, Duration, Fn, IResource, Lazy, Resource, Stack, Tags } from '@aws-cdk/core';
55
import { CloudFormationInit } from './cfn-init';
66
import { Connections, IConnectable } from './connections';
77
import { CfnInstance } from './ec2.generated';
@@ -333,13 +333,13 @@ export class Instance extends Resource implements IInstance {
333333
if (selected.length === 1) {
334334
subnet = selected[0];
335335
} else {
336-
this.node.addError(`Need exactly 1 subnet to match AZ '${props.availabilityZone}', found ${selected.length}. Use a different availabilityZone.`);
336+
Annotations.of(this).addError(`Need exactly 1 subnet to match AZ '${props.availabilityZone}', found ${selected.length}. Use a different availabilityZone.`);
337337
}
338338
} else {
339339
if (subnets.length > 0) {
340340
subnet = subnets[0];
341341
} else {
342-
this.node.addError(`Did not find any subnets matching '${JSON.stringify(props.vpcSubnets)}', please use a different selection.`);
342+
Annotations.of(this).addError(`Did not find any subnets matching '${JSON.stringify(props.vpcSubnets)}', please use a different selection.`);
343343
}
344344
}
345345
if (!subnet) {

packages/@aws-cdk/aws-ec2/lib/private/cfn-init-internal.ts

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ export interface InitElementConfig {
7272
* @default - No authentication associated with the config
7373
*/
7474
readonly authentication?: Record<string, any>;
75+
76+
/**
77+
* Optional string representing a hash of the asset associated with this element (if any).
78+
*
79+
* @default - No hash is provided
80+
*/
81+
readonly assetHash?: string;
7582
}
7683

7784
/**

packages/@aws-cdk/aws-ec2/lib/security-group.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Construct, IResource, Lazy, Resource, ResourceProps, Stack, Token } from '@aws-cdk/core';
1+
import { Annotations, Construct, IResource, Lazy, Resource, ResourceProps, Stack, Token } from '@aws-cdk/core';
22
import { Connections } from './connections';
33
import { CfnSecurityGroup, CfnSecurityGroupEgress, CfnSecurityGroupIngress } from './ec2.generated';
44
import { IPeer } from './peer';
@@ -404,7 +404,7 @@ export class SecurityGroup extends SecurityGroupBase {
404404
// In the case of "allowAllOutbound", we don't add any more rules. There
405405
// is only one rule which allows all traffic and that subsumes any other
406406
// rule.
407-
this.node.addWarning('Ignoring Egress rule since \'allowAllOutbound\' is set to true; To add customize rules, set allowAllOutbound=false on the SecurityGroup');
407+
Annotations.of(this).addWarning('Ignoring Egress rule since \'allowAllOutbound\' is set to true; To add customize rules, set allowAllOutbound=false on the SecurityGroup');
408408
return;
409409
} else {
410410
// Otherwise, if the bogus rule exists we can now remove it because the

packages/@aws-cdk/aws-ec2/lib/volume.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as crypto from 'crypto';
22

33
import { AccountRootPrincipal, Grant, IGrantable } from '@aws-cdk/aws-iam';
44
import { IKey, ViaServicePrincipal } from '@aws-cdk/aws-kms';
5-
import { Construct, IResource, Resource, Size, SizeRoundingBehavior, Stack, Token, Tags } from '@aws-cdk/core';
5+
import { Annotations, Construct, IResource, Resource, Size, SizeRoundingBehavior, Stack, Token, Tags } from '@aws-cdk/core';
66
import { CfnInstance, CfnVolume } from './ec2.generated';
77
import { IInstance } from './instance';
88

@@ -176,7 +176,7 @@ export function synthesizeBlockDeviceMappings(construct: Construct, blockDevices
176176
throw new Error('iops property is required with volumeType: EbsDeviceVolumeType.IO1');
177177
}
178178
} else if (volumeType !== EbsDeviceVolumeType.IO1) {
179-
construct.node.addWarning('iops will be ignored without volumeType: EbsDeviceVolumeType.IO1');
179+
Annotations.of(construct).addWarning('iops will be ignored without volumeType: EbsDeviceVolumeType.IO1');
180180
}
181181
}
182182

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
22
import {
3-
ConcreteDependable, Construct, ContextProvider, DependableTrait, IConstruct,
3+
Annotations, ConcreteDependable, Construct, ContextProvider, DependableTrait, IConstruct,
44
IDependable, IResource, Lazy, Resource, Stack, Token, Tags,
55
} from '@aws-cdk/core';
66
import * as cxapi from '@aws-cdk/cx-api';
@@ -380,7 +380,7 @@ abstract class VpcBase extends Resource implements IVpc {
380380
const routeTableIds = allRouteTableIds(flatten(vpnRoutePropagation.map(s => this.selectSubnets(s).subnets)));
381381

382382
if (routeTableIds.length === 0) {
383-
this.node.addError(`enableVpnGateway: no subnets matching selection: '${JSON.stringify(vpnRoutePropagation)}'. Select other subnets to add routes to.`);
383+
Annotations.of(this).addError(`enableVpnGateway: no subnets matching selection: '${JSON.stringify(vpnRoutePropagation)}'. Select other subnets to add routes to.`);
384384
}
385385

386386
const routePropagation = new CfnVPNGatewayRoutePropagation(this, 'RoutePropagation', {
@@ -1899,7 +1899,7 @@ class ImportedSubnet extends Resource implements ISubnet, IPublicSubnet, IPrivat
18991899
? `at '${scope.node.path}/${id}'`
19001900
: `'${attrs.subnetId}'`;
19011901
// eslint-disable-next-line max-len
1902-
scope.node.addWarning(`No routeTableId was provided to the subnet ${ref}. Attempting to read its .routeTable.routeTableId will return null/undefined. (More info: https://github.com/aws/aws-cdk/pull/3171)`);
1902+
Annotations.of(this).addWarning(`No routeTableId was provided to the subnet ${ref}. Attempting to read its .routeTable.routeTableId will return null/undefined. (More info: https://github.com/aws/aws-cdk/pull/3171)`);
19031903
}
19041904

19051905
this._availabilityZone = attrs.availabilityZone;

0 commit comments

Comments
 (0)