Skip to content

Commit 2b759ca

Browse files
authoredDec 8, 2021
fix(assets): remove the original-path metadata (#17901)
Revert `aws:asset:original-path` to fix #17706
1 parent d5c249f commit 2b759ca

File tree

6 files changed

+3
-24
lines changed

6 files changed

+3
-24
lines changed
 

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ 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,
7877
[cxapi.ASSET_RESOURCE_METADATA_IS_BUNDLED_KEY]: false,
7978
[cxapi.ASSET_RESOURCE_METADATA_PROPERTY_KEY]: 'Code',
8079
},
@@ -464,9 +463,8 @@ describe('code', () => {
464463
stack.node.setContext(cxapi.ASSET_RESOURCE_METADATA_ENABLED_CONTEXT, true);
465464

466465
// when
467-
const FunctionCodepath = path.join(__dirname, 'docker-build-lambda');
468466
new lambda.Function(stack, 'Fn', {
469-
code: lambda.Code.fromDockerBuild(FunctionCodepath),
467+
code: lambda.Code.fromDockerBuild(path.join(__dirname, 'docker-build-lambda')),
470468
handler: 'index.handler',
471469
runtime: lambda.Runtime.NODEJS_12_X,
472470
});
@@ -475,7 +473,6 @@ describe('code', () => {
475473
expect(stack).toHaveResource('AWS::Lambda::Function', {
476474
Metadata: {
477475
[cxapi.ASSET_RESOURCE_METADATA_PATH_KEY]: 'asset.fbafdbb9ae8d1bae0def415b791a93c486d18ebc63270c748abecc3ac0ab9533',
478-
[cxapi.ASSET_RESOURCE_METADATA_ORIGINAL_PATH_KEY]: FunctionCodepath,
479476
[cxapi.ASSET_RESOURCE_METADATA_IS_BUNDLED_KEY]: false,
480477
[cxapi.ASSET_RESOURCE_METADATA_PROPERTY_KEY]: 'Code',
481478
},

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,14 @@ describe('layers', () => {
7474
stack.node.setContext(cxapi.ASSET_RESOURCE_METADATA_ENABLED_CONTEXT, true);
7575

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

8281
// THEN
8382
expect(canonicalizeTemplate(SynthUtils.toCloudFormation(stack))).toHaveResource('AWS::Lambda::LayerVersion', {
8483
Metadata: {
8584
'aws:asset:path': 'asset.Asset1Hash',
86-
'aws:asset:original-path': layerCodePath,
8785
'aws:asset:is-bundled': false,
8886
'aws:asset:property': 'Content',
8987
},

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

-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ describe('log retention', () => {
196196
expect(stack).toHaveResource('AWS::Lambda::Function', {
197197
Metadata: {
198198
'aws:asset:path': assetLocation,
199-
'aws:asset:original-path': assetLocation,
200199
'aws:asset:is-bundled': false,
201200
'aws:asset:property': 'Code',
202201
},

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

+1-11
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,6 @@ 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-
131123
/**
132124
* Indicates if this asset got bundled before staged, or not.
133125
*/
@@ -136,13 +128,12 @@ export class Asset extends CoreConstruct implements cdk.IAsset {
136128
constructor(scope: Construct, id: string, props: AssetProps) {
137129
super(scope, id);
138130

139-
this.originalAssetPath = path.resolve(props.path);
140131
this.isBundled = props.bundling != null;
141132

142133
// stage the asset source (conditionally).
143134
const staging = new cdk.AssetStaging(this, 'Stage', {
144135
...props,
145-
sourcePath: this.originalAssetPath,
136+
sourcePath: path.resolve(props.path),
146137
follow: props.followSymlinks ?? toSymlinkFollow(props.follow),
147138
assetHash: props.assetHash ?? props.sourceHash,
148139
});
@@ -207,7 +198,6 @@ export class Asset extends CoreConstruct implements cdk.IAsset {
207198
// points to a local path in order to enable local invocation of this function.
208199
resource.cfnOptions.metadata = resource.cfnOptions.metadata || { };
209200
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_PATH_KEY] = this.assetPath;
210-
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_ORIGINAL_PATH_KEY] = this.originalAssetPath;
211201
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_IS_BUNDLED_KEY] = this.isBundled;
212202
resource.cfnOptions.metadata[cxapi.ASSET_RESOURCE_METADATA_PROPERTY_KEY] = resourceProperty;
213203
}

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

-4
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ 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,
207206
'aws:asset:is-bundled': false,
208207
'aws:asset:property': 'PropName',
209208
},
@@ -224,7 +223,6 @@ test('asset metadata is only emitted if ASSET_RESOURCE_METADATA_ENABLED_CONTEXT
224223
expect(stack).not.toHaveResource('My::Resource::Type', {
225224
Metadata: {
226225
'aws:asset:path': SAMPLE_ASSET_DIR,
227-
'aws:asset:original-path': SAMPLE_ASSET_DIR,
228226
'aws:asset:is-bundled': false,
229227
'aws:asset:property': 'PropName',
230228
},
@@ -355,7 +353,6 @@ describe('staging', () => {
355353
const template = SynthUtils.synthesize(stack).template;
356354
expect(template.Resources.MyResource.Metadata).toEqual({
357355
'aws:asset:path': 'asset.6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2',
358-
'aws:asset:original-path': SAMPLE_ASSET_DIR,
359356
'aws:asset:is-bundled': false,
360357
'aws:asset:property': 'PropName',
361358
});
@@ -383,7 +380,6 @@ describe('staging', () => {
383380
const template = SynthUtils.synthesize(stack).template;
384381
expect(template.Resources.MyResource.Metadata).toEqual({
385382
'aws:asset:path': SAMPLE_ASSET_DIR,
386-
'aws:asset:original-path': SAMPLE_ASSET_DIR,
387383
'aws:asset:is-bundled': false,
388384
'aws:asset:property': 'PropName',
389385
});

‎packages/@aws-cdk/cx-api/lib/assets.ts

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export const ASSET_RESOURCE_METADATA_DOCKER_BUILD_ARGS_KEY = 'aws:asset:docker-b
1515
export const ASSET_RESOURCE_METADATA_DOCKER_BUILD_TARGET_KEY = 'aws:asset:docker-build-target';
1616
export const ASSET_RESOURCE_METADATA_PROPERTY_KEY = 'aws:asset:property';
1717
export const ASSET_RESOURCE_METADATA_IS_BUNDLED_KEY = 'aws:asset:is-bundled';
18-
export const ASSET_RESOURCE_METADATA_ORIGINAL_PATH_KEY = 'aws:asset:original-path';
1918

2019
/**
2120
* Separator string that separates the prefix separator from the object key separator.

0 commit comments

Comments
 (0)
Please sign in to comment.