Skip to content

Commit e81f61f

Browse files
authored
Merge branch 'master' into merge-back/1.133.0
2 parents 2dea31a + 34af598 commit e81f61f

File tree

11 files changed

+144
-13
lines changed

11 files changed

+144
-13
lines changed

packages/@aws-cdk/aws-elasticsearch/lib/domain.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,9 +1403,8 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
14031403
return instanceTypes.some(isInstanceType);
14041404
};
14051405

1406-
function isEveryInstanceType(...instanceTypes: string[]): Boolean {
1407-
return instanceTypes.some(t => dedicatedMasterType.startsWith(t))
1408-
&& instanceTypes.some(t => instanceType.startsWith(t));
1406+
function isEveryDatanodeInstanceType(...instanceTypes: string[]): Boolean {
1407+
return instanceTypes.some(t => instanceType.startsWith(t));
14091408
};
14101409

14111410
// Validate feature support for the given Elasticsearch version, per
@@ -1464,7 +1463,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
14641463

14651464
// Only R3, I3 and r6gd support instance storage, per
14661465
// https://aws.amazon.com/elasticsearch-service/pricing/
1467-
if (!ebsEnabled && !isEveryInstanceType('r3', 'i3', 'r6gd')) {
1466+
if (!ebsEnabled && !isEveryDatanodeInstanceType('r3', 'i3', 'r6gd')) {
14681467
throw new Error('EBS volumes are required when using instance types other than r3, i3 or r6gd.');
14691468
}
14701469

packages/@aws-cdk/aws-elasticsearch/test/domain.test.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ describe('custom error responses', () => {
14371437
})).toThrow(/Node-to-node encryption requires Elasticsearch version 6.0 or later/);
14381438
});
14391439

1440-
test('error when i3 instance types are specified with EBS enabled', () => {
1440+
test('error when i3 or r6g instance types are specified with EBS enabled', () => {
14411441
expect(() => new Domain(stack, 'Domain1', {
14421442
version: ElasticsearchVersion.V7_4,
14431443
capacity: {
@@ -1448,6 +1448,16 @@ describe('custom error responses', () => {
14481448
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
14491449
},
14501450
})).toThrow(/I3 and R6GD instance types do not support EBS storage volumes/);
1451+
expect(() => new Domain(stack, 'Domain2', {
1452+
version: ElasticsearchVersion.V7_4,
1453+
capacity: {
1454+
dataNodeInstanceType: 'r6gd.large.elasticsearch',
1455+
},
1456+
ebs: {
1457+
volumeSize: 100,
1458+
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
1459+
},
1460+
})).toThrow(/I3 and R6GD instance types do not support EBS storage volumes/);
14511461
});
14521462

14531463
test('error when m3, r3, or t2 instance types are specified with encryption at rest enabled', () => {
@@ -1500,6 +1510,41 @@ describe('custom error responses', () => {
15001510
masterNodeInstanceType: 'm5.large.elasticsearch',
15011511
},
15021512
})).toThrow(/EBS volumes are required when using instance types other than r3, i3 or r6gd/);
1513+
expect(() => new Domain(stack, 'Domain2', {
1514+
version: ElasticsearchVersion.V7_4,
1515+
ebs: {
1516+
enabled: false,
1517+
},
1518+
capacity: {
1519+
dataNodeInstanceType: 'm5.large.elasticsearch',
1520+
},
1521+
})).toThrow(/EBS volumes are required when using instance types other than r3, i3 or r6gd/);
1522+
});
1523+
1524+
test('can use compatible master instance types that does not have local storage when data node type is i3 or r6gd', () => {
1525+
new Domain(stack, 'Domain1', {
1526+
version: ElasticsearchVersion.V7_4,
1527+
ebs: {
1528+
enabled: false,
1529+
},
1530+
capacity: {
1531+
masterNodeInstanceType: 'c5.2xlarge.elasticsearch',
1532+
dataNodeInstanceType: 'i3.2xlarge.elasticsearch',
1533+
},
1534+
});
1535+
new Domain(stack, 'Domain2', {
1536+
version: ElasticsearchVersion.V7_4,
1537+
ebs: {
1538+
enabled: false,
1539+
},
1540+
capacity: {
1541+
masterNodes: 3,
1542+
masterNodeInstanceType: 'c6g.large.elasticsearch',
1543+
dataNodeInstanceType: 'r6gd.large.elasticsearch',
1544+
},
1545+
});
1546+
// both configurations pass synth-time validation
1547+
expect(stack).toCountResources('AWS::Elasticsearch::Domain', 2);
15031548
});
15041549

15051550
test('error when availabilityZoneCount is not 2 or 3', () => {

packages/@aws-cdk/aws-lambda/test/code.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ describe('code', () => {
7474
expect(stack).toHaveResource('AWS::Lambda::Function', {
7575
Metadata: {
7676
[cxapi.ASSET_RESOURCE_METADATA_PATH_KEY]: 'asset.9678c34eca93259d11f2d714177347afd66c50116e1e08996eff893d3ca81232',
77+
[cxapi.ASSET_RESOURCE_METADATA_ORIGINAL_PATH_KEY]: location,
78+
[cxapi.ASSET_RESOURCE_METADATA_IS_BUNDLED_KEY]: false,
7779
[cxapi.ASSET_RESOURCE_METADATA_PROPERTY_KEY]: 'Code',
7880
},
7981
}, ResourcePart.CompleteDefinition);
@@ -462,8 +464,9 @@ describe('code', () => {
462464
stack.node.setContext(cxapi.ASSET_RESOURCE_METADATA_ENABLED_CONTEXT, true);
463465

464466
// when
467+
const FunctionCodepath = path.join(__dirname, 'docker-build-lambda');
465468
new lambda.Function(stack, 'Fn', {
466-
code: lambda.Code.fromDockerBuild(path.join(__dirname, 'docker-build-lambda')),
469+
code: lambda.Code.fromDockerBuild(FunctionCodepath),
467470
handler: 'index.handler',
468471
runtime: lambda.Runtime.NODEJS_12_X,
469472
});
@@ -472,6 +475,8 @@ describe('code', () => {
472475
expect(stack).toHaveResource('AWS::Lambda::Function', {
473476
Metadata: {
474477
[cxapi.ASSET_RESOURCE_METADATA_PATH_KEY]: 'asset.fbafdbb9ae8d1bae0def415b791a93c486d18ebc63270c748abecc3ac0ab9533',
478+
[cxapi.ASSET_RESOURCE_METADATA_ORIGINAL_PATH_KEY]: FunctionCodepath,
479+
[cxapi.ASSET_RESOURCE_METADATA_IS_BUNDLED_KEY]: false,
475480
[cxapi.ASSET_RESOURCE_METADATA_PROPERTY_KEY]: 'Code',
476481
},
477482
}, ResourcePart.CompleteDefinition);

packages/@aws-cdk/aws-lambda/test/layers.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,17 @@ describe('layers', () => {
7474
stack.node.setContext(cxapi.ASSET_RESOURCE_METADATA_ENABLED_CONTEXT, true);
7575

7676
// WHEN
77+
let layerCodePath = path.join(__dirname, 'layer-code');
7778
new lambda.LayerVersion(stack, 'layer', {
78-
code: lambda.Code.fromAsset(path.join(__dirname, 'layer-code')),
79+
code: lambda.Code.fromAsset(layerCodePath),
7980
});
8081

8182
// THEN
8283
expect(canonicalizeTemplate(SynthUtils.toCloudFormation(stack))).toHaveResource('AWS::Lambda::LayerVersion', {
8384
Metadata: {
8485
'aws:asset:path': 'asset.Asset1Hash',
86+
'aws:asset:original-path': layerCodePath,
87+
'aws:asset:is-bundled': false,
8588
'aws:asset:property': 'Content',
8689
},
8790
}, ResourcePart.CompleteDefinition);

packages/@aws-cdk/aws-logs/test/log-retention.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ describe('log retention', () => {
196196
expect(stack).toHaveResource('AWS::Lambda::Function', {
197197
Metadata: {
198198
'aws:asset:path': assetLocation,
199+
'aws:asset:original-path': assetLocation,
200+
'aws:asset:is-bundled': false,
199201
'aws:asset:property': 'Code',
200202
},
201203
}, ResourcePart.CompleteDefinition);

packages/@aws-cdk/aws-msk/lib/cluster-version.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export class KafkaVersion {
3737
*/
3838
public static readonly V2_6_1 = KafkaVersion.of('2.6.1');
3939

40+
/**
41+
* Kafka version 2.6.2
42+
*/
43+
public static readonly V2_6_2 = KafkaVersion.of('2.6.2');
44+
4045
/**
4146
* Kafka version 2.7.0
4247
*/

packages/@aws-cdk/aws-opensearchservice/lib/domain.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,9 +1320,8 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
13201320
return instanceTypes.some(isInstanceType);
13211321
};
13221322

1323-
function isEveryInstanceType(...instanceTypes: string[]): Boolean {
1324-
return instanceTypes.some(t => dedicatedMasterType.startsWith(t))
1325-
&& instanceTypes.some(t => instanceType.startsWith(t));
1323+
function isEveryDatanodeInstanceType(...instanceTypes: string[]): Boolean {
1324+
return instanceTypes.some(t => instanceType.startsWith(t));
13261325
};
13271326

13281327
// Validate feature support for the given Elasticsearch/OpenSearch version, per
@@ -1396,7 +1395,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
13961395

13971396
// Only R3, I3 and r6gd support instance storage, per
13981397
// https://aws.amazon.com/opensearch-service/pricing/
1399-
if (!ebsEnabled && !isEveryInstanceType('r3', 'i3', 'r6gd')) {
1398+
if (!ebsEnabled && !isEveryDatanodeInstanceType('r3', 'i3', 'r6gd')) {
14001399
throw new Error('EBS volumes are required when using instance types other than r3, i3 or r6gd.');
14011400
}
14021401

packages/@aws-cdk/aws-opensearchservice/test/domain.test.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ describe('custom error responses', () => {
14391439
})).toThrow(/Node-to-node encryption requires Elasticsearch version 6.0 or later or OpenSearch version 1.0 or later/);
14401440
});
14411441

1442-
test('error when i3 instance types are specified with EBS enabled', () => {
1442+
test('error when i3 or r6g instance types are specified with EBS enabled', () => {
14431443
expect(() => new Domain(stack, 'Domain1', {
14441444
version: defaultVersion,
14451445
capacity: {
@@ -1450,6 +1450,16 @@ describe('custom error responses', () => {
14501450
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
14511451
},
14521452
})).toThrow(/I3 and R6GD instance types do not support EBS storage volumes/);
1453+
expect(() => new Domain(stack, 'Domain2', {
1454+
version: defaultVersion,
1455+
capacity: {
1456+
dataNodeInstanceType: 'r6gd.large.search',
1457+
},
1458+
ebs: {
1459+
volumeSize: 100,
1460+
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
1461+
},
1462+
})).toThrow(/I3 and R6GD instance types do not support EBS storage volumes/);
14531463
});
14541464

14551465
test('error when m3, r3, or t2 instance types are specified with encryption at rest enabled', () => {
@@ -1502,6 +1512,41 @@ describe('custom error responses', () => {
15021512
masterNodeInstanceType: 'm5.large.search',
15031513
},
15041514
})).toThrow(/EBS volumes are required when using instance types other than r3, i3 or r6gd/);
1515+
expect(() => new Domain(stack, 'Domain2', {
1516+
version: defaultVersion,
1517+
ebs: {
1518+
enabled: false,
1519+
},
1520+
capacity: {
1521+
dataNodeInstanceType: 'm5.large.search',
1522+
},
1523+
})).toThrow(/EBS volumes are required when using instance types other than r3, i3 or r6gd/);
1524+
});
1525+
1526+
test('can use compatible master instance types that does not have local storage when data node type is i3 or r6gd', () => {
1527+
new Domain(stack, 'Domain1', {
1528+
version: defaultVersion,
1529+
ebs: {
1530+
enabled: false,
1531+
},
1532+
capacity: {
1533+
masterNodeInstanceType: 'c5.2xlarge.search',
1534+
dataNodeInstanceType: 'i3.2xlarge.search',
1535+
},
1536+
});
1537+
new Domain(stack, 'Domain2', {
1538+
version: defaultVersion,
1539+
ebs: {
1540+
enabled: false,
1541+
},
1542+
capacity: {
1543+
masterNodes: 3,
1544+
masterNodeInstanceType: 'c6g.large.search',
1545+
dataNodeInstanceType: 'r6gd.large.search',
1546+
},
1547+
});
1548+
// both configurations pass synth-time validation
1549+
expect(stack).toCountResources('AWS::OpenSearchService::Domain', 2);
15051550
});
15061551

15071552
test('error when availabilityZoneCount is not 2 or 3', () => {

packages/@aws-cdk/aws-s3-assets/lib/asset.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,29 @@ export class Asset extends CoreConstruct implements cdk.IAsset {
120120

121121
public readonly assetHash: string;
122122

123+
/**
124+
* The original Asset Path before it got staged.
125+
*
126+
* If asset staging is disabled, this will be same value as assetPath.
127+
* If asset staging is enabled, it will be the Asset original path before staging.
128+
*/
129+
private readonly originalAssetPath: string;
130+
131+
/**
132+
* Indicates if this asset got bundled before staged, or not.
133+
*/
134+
private readonly isBundled: boolean;
135+
123136
constructor(scope: Construct, id: string, props: AssetProps) {
124137
super(scope, id);
125138

139+
this.originalAssetPath = path.resolve(props.path);
140+
this.isBundled = props.bundling != null;
141+
126142
// stage the asset source (conditionally).
127143
const staging = new cdk.AssetStaging(this, 'Stage', {
128144
...props,
129-
sourcePath: path.resolve(props.path),
145+
sourcePath: this.originalAssetPath,
130146
follow: props.followSymlinks ?? toSymlinkFollow(props.follow),
131147
assetHash: props.assetHash ?? props.sourceHash,
132148
});
@@ -191,6 +207,8 @@ export class Asset extends CoreConstruct implements cdk.IAsset {
191207
// points to a local path in order to enable local invocation of this function.
192208
resource.cfnOptions.metadata = resource.cfnOptions.metadata || { };
193209
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_PATH_KEY] = this.assetPath;
210+
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_ORIGINAL_PATH_KEY] = this.originalAssetPath;
211+
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_IS_BUNDLED_KEY] = this.isBundled;
194212
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_PROPERTY_KEY] = resourceProperty;
195213
}
196214

packages/@aws-cdk/aws-s3-assets/test/asset.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ test('addResourceMetadata can be used to add CFN metadata to resources', () => {
203203
expect(stack).toHaveResource('My::Resource::Type', {
204204
Metadata: {
205205
'aws:asset:path': 'asset.6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2',
206+
'aws:asset:original-path': location,
207+
'aws:asset:is-bundled': false,
206208
'aws:asset:property': 'PropName',
207209
},
208210
}, ResourcePart.CompleteDefinition);
@@ -222,6 +224,8 @@ test('asset metadata is only emitted if ASSET_RESOURCE_METADATA_ENABLED_CONTEXT
222224
expect(stack).not.toHaveResource('My::Resource::Type', {
223225
Metadata: {
224226
'aws:asset:path': SAMPLE_ASSET_DIR,
227+
'aws:asset:original-path': SAMPLE_ASSET_DIR,
228+
'aws:asset:is-bundled': false,
225229
'aws:asset:property': 'PropName',
226230
},
227231
}, ResourcePart.CompleteDefinition);
@@ -351,6 +355,8 @@ describe('staging', () => {
351355
const template = SynthUtils.synthesize(stack).template;
352356
expect(template.Resources.MyResource.Metadata).toEqual({
353357
'aws:asset:path': 'asset.6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2',
358+
'aws:asset:original-path': SAMPLE_ASSET_DIR,
359+
'aws:asset:is-bundled': false,
354360
'aws:asset:property': 'PropName',
355361
});
356362
});
@@ -377,6 +383,8 @@ describe('staging', () => {
377383
const template = SynthUtils.synthesize(stack).template;
378384
expect(template.Resources.MyResource.Metadata).toEqual({
379385
'aws:asset:path': SAMPLE_ASSET_DIR,
386+
'aws:asset:original-path': SAMPLE_ASSET_DIR,
387+
'aws:asset:is-bundled': false,
380388
'aws:asset:property': 'PropName',
381389
});
382390
});

0 commit comments

Comments
 (0)