Skip to content

Commit f19fc39

Browse files
authoredDec 7, 2021
fix(lambda): recognizeVersionProps featureFlag not defaulting correctly (#17866)
The `@aws-cdk/aws-lambda:recognizeVersionProps` feature flag has always had the "future" behavior set to "true", meaning any new projects get the flag set to true. All of these style flags were intended to default to true as well for v2, but this one was missed. The end result is that users who have created a new v1 project anytime in the last ~6 months, and then upgrade to v2, actually experience a _downgrade_ in behavior if following the offical migration guide (which instructs users to delete all feature flags). This change fixes the behavior to work as intended. Users who wish to opt out can continue to set `@aws-cdk/aws-lambda:recognizeVersionProps` to false in their `cdk.json`. fixes #17810 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 7fb639a commit f19fc39

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed
 

‎packages/@aws-cdk/aws-cloudfront/test/distribution.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import '@aws-cdk/assert-internal/jest';
33
import * as acm from '@aws-cdk/aws-certificatemanager';
44
import * as lambda from '@aws-cdk/aws-lambda';
55
import * as s3 from '@aws-cdk/aws-s3';
6+
import { testFutureBehavior, testLegacyBehavior } from '@aws-cdk/cdk-build-tools/lib/feature-flag';
67
import { App, Duration, Stack } from '@aws-cdk/core';
78
import { CLOUDFRONT_DEFAULT_SECURITY_POLICY_TLS_V1_2_2021 } from '@aws-cdk/cx-api';
8-
import { testFutureBehavior, testLegacyBehavior } from '@aws-cdk/cdk-build-tools/lib/feature-flag';
99
import {
1010
CfnDistribution,
1111
Distribution,
@@ -595,7 +595,7 @@ describe('with Lambda@Edge functions', () => {
595595
EventType: 'origin-request',
596596
IncludeBody: true,
597597
LambdaFunctionARN: {
598-
Ref: 'FunctionCurrentVersion4E2B2261477a5ae8059bbaa7813f752292c0f65e',
598+
Ref: 'FunctionCurrentVersion4E2B2261f9b8c8b9c774af866281167c3323362d',
599599
},
600600
},
601601
],
@@ -665,7 +665,7 @@ describe('with Lambda@Edge functions', () => {
665665
{
666666
EventType: 'viewer-request',
667667
LambdaFunctionARN: {
668-
Ref: 'FunctionCurrentVersion4E2B2261477a5ae8059bbaa7813f752292c0f65e',
668+
Ref: 'FunctionCurrentVersion4E2B2261f9b8c8b9c774af866281167c3323362d',
669669
},
670670
},
671671
],
@@ -771,7 +771,7 @@ describe('with Lambda@Edge functions', () => {
771771
{
772772
EventType: 'origin-request',
773773
LambdaFunctionARN: {
774-
Ref: 'SingletonLambdasingletonforcloudfrontCurrentVersion0078406348a0962a52448a200cd0dbc0e22edb2a',
774+
Ref: 'SingletonLambdasingletonforcloudfrontCurrentVersion00784063de5dfb6e46a8d2a0436a69c9a8bfabae',
775775
},
776776
},
777777
],

‎packages/@aws-cdk/aws-cloudfront/test/experimental/edge-function.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe('stacks', () => {
9797
});
9898
expect(fnStack).toHaveResource('AWS::SSM::Parameter', {
9999
Type: 'String',
100-
Value: { Ref: 'MyFnCurrentVersion309B29FC29686ce94039b6e08d1645be854b3ac9' },
100+
Value: { Ref: 'MyFnCurrentVersion309B29FC37a9dfc56f4df872af37f8a33a191788' },
101101
Name: '/cdk/EdgeFunctionArn/testregion/Stack/MyFn',
102102
});
103103
});

‎packages/@aws-cdk/aws-cloudfront/test/web-distribution.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ describe('web distribution', () => {
290290
const sourceBucket = new s3.Bucket(stack, 'Bucket');
291291

292292
new CloudFrontWebDistribution(stack, 'AnAmazingWebsiteProbably', {
293-
comment: `Adding a comment longer than 128 characters should be trimmed and
293+
comment: `Adding a comment longer than 128 characters should be trimmed and
294294
added the ellipsis so a user would know there was more to read and everything beyond this point should not show up`,
295295
originConfigs: [
296296
{
@@ -344,8 +344,8 @@ added the ellipsis so a user would know there was more to read and everything be
344344
},
345345
Compress: true,
346346
},
347-
Comment: `Adding a comment longer than 128 characters should be trimmed and
348-
added the ellipsis so a user would know there was more to ...`,
347+
Comment: `Adding a comment longer than 128 characters should be trimmed and
348+
added the ellipsis so a user would know there was more to r...`,
349349
Enabled: true,
350350
IPV6Enabled: true,
351351
HttpVersion: 'http2',
@@ -871,7 +871,7 @@ added the ellipsis so a user would know there was more to ...`,
871871
'EventType': 'origin-request',
872872
'IncludeBody': true,
873873
'LambdaFunctionARN': {
874-
'Ref': 'LambdaCurrentVersionDF706F6A97fb843e9bd06fcd2bb15eeace80e13e',
874+
'Ref': 'LambdaCurrentVersionDF706F6A25bf7d67df4eb614ea2e1ea69c8759b6',
875875
},
876876
},
877877
],

‎packages/@aws-cdk/aws-lambda/test/function-hash.test.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('function hash', () => {
4444
});
4545

4646
expect(calculateFunctionHash(fn1)).toEqual(calculateFunctionHash(fn2));
47-
expect(calculateFunctionHash(fn1)).toEqual('aea5463dba236007afe91d2832b3c836');
47+
expect(calculateFunctionHash(fn1)).toEqual('e5235e3cb7a9b70c42c1a665a3ebd77c');
4848
});
4949
});
5050

@@ -61,8 +61,8 @@ describe('function hash', () => {
6161
handler: 'index.handler',
6262
});
6363

64-
expect(calculateFunctionHash(fn1)).not.toEqual('aea5463dba236007afe91d2832b3c836');
65-
expect(calculateFunctionHash(fn1)).toEqual('979b4a14c6f174c745cdbcd1036cf844');
64+
expect(calculateFunctionHash(fn1)).not.toEqual('e5235e3cb7a9b70c42c1a665a3ebd77c');
65+
expect(calculateFunctionHash(fn1)).toEqual('bb95ae2489ebc480a23ff373362e453a');
6666
});
6767

6868
test('environment variables impact hash', () => {
@@ -91,8 +91,8 @@ describe('function hash', () => {
9191
},
9292
});
9393

94-
expect(calculateFunctionHash(fn1)).toEqual('d1bc824ac5022b7d62d8b12dbae6580c');
95-
expect(calculateFunctionHash(fn2)).toEqual('3b683d05465012b0aa9c4ff53b32f014');
94+
expect(calculateFunctionHash(fn1)).toEqual('a072f10967c25eb87c187e3d61d88f58');
95+
expect(calculateFunctionHash(fn2)).toEqual('29aa77e049793f5424d31e880d6ce535');
9696
});
9797

9898
test('runtime impacts hash', () => {
@@ -121,8 +121,8 @@ describe('function hash', () => {
121121
},
122122
});
123123

124-
expect(calculateFunctionHash(fn1)).toEqual('d1bc824ac5022b7d62d8b12dbae6580c');
125-
expect(calculateFunctionHash(fn2)).toEqual('0f168f0772463e8e547bb3800937e54d');
124+
expect(calculateFunctionHash(fn1)).toEqual('a072f10967c25eb87c187e3d61d88f58');
125+
expect(calculateFunctionHash(fn2)).toEqual('c27e1d43e5595311b185324306244f1b');
126126
});
127127

128128
test('inline code change impacts the hash', () => {
@@ -140,8 +140,8 @@ describe('function hash', () => {
140140
handler: 'index.handler',
141141
});
142142

143-
expect(calculateFunctionHash(fn1)).toEqual('ebf2e871fc6a3062e8bdcc5ebe16db3f');
144-
expect(calculateFunctionHash(fn2)).toEqual('ffedf6424a18a594a513129dc97bf53c');
143+
expect(calculateFunctionHash(fn1)).toEqual('ae3a05e0797a7b59e850d453a2e8ea97');
144+
expect(calculateFunctionHash(fn2)).toEqual('bdce872a679fc58e06ab8b0cd30ffb37');
145145
});
146146

147147
describe('impact of env variables order on hash', () => {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe('lambda version', () => {
123123
},
124124
FunctionVersion: {
125125
'Fn::GetAtt': [
126-
'FnCurrentVersion17A89ABBab5c765f3c55e4e61583b51b00a95742',
126+
'FnCurrentVersion17A89ABB60415807620115f34aaea569cf042980',
127127
'Version',
128128
],
129129
},
@@ -142,7 +142,7 @@ describe('lambda version', () => {
142142
const version = fn.currentVersion;
143143

144144
// THEN
145-
expect(stack.resolve(version.edgeArn)).toEqual({ Ref: 'FnCurrentVersion17A89ABB19ed45993ff69fd011ae9fd4ab6e2005' });
145+
expect(stack.resolve(version.edgeArn)).toEqual({ Ref: 'FnCurrentVersion17A89ABB60415807620115f34aaea569cf042980' });
146146
});
147147

148148
test('edgeArn throws with $LATEST', () => {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ const FUTURE_FLAGS_DEFAULTS: { [key: string]: boolean } = {
224224
[ECS_REMOVE_DEFAULT_DESIRED_COUNT]: true,
225225
[RDS_LOWERCASE_DB_IDENTIFIER]: true,
226226
[EFS_DEFAULT_ENCRYPTION_AT_REST]: true,
227-
[LAMBDA_RECOGNIZE_VERSION_PROPS]: false,
227+
[LAMBDA_RECOGNIZE_VERSION_PROPS]: true,
228228
[CLOUDFRONT_DEFAULT_SECURITY_POLICY_TLS_V1_2_2021]: true,
229229
};
230230

0 commit comments

Comments
 (0)
Please sign in to comment.