Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): 2.43.0 #22176

Merged
merged 27 commits into from
Sep 21, 2022
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b3c9464
fix(certificatemanager): unable to set removal policy on DnsValidated…
corymhall Sep 15, 2022
2e797b5
Revert "fix(certificatemanager): unable to set removal policy on DnsV…
corymhall Sep 15, 2022
22a1a8c
Merge branch 'main' into merge-back/2.42.0
mergify[bot] Sep 16, 2022
5fc7ca2
chore(merge-back): 2.42.0 (#22084)
mergify[bot] Sep 16, 2022
d0e0ab9
fix(integ-tests): can't enable lookups when creating an IntegTest (#2…
corymhall Sep 17, 2022
ce27789
fix(codedeploy): unable to configure disable automatically rollback (…
msysh Sep 17, 2022
b8c2abf
docs(aws-lambda): mark NODEJS_12_X as deprecated (#22093)
coderbyheart Sep 19, 2022
8280709
fix(cli): Lambda hotswap fails if environment contains tokens (#22099)
tmokmss Sep 19, 2022
dbede40
feat(ec2): flowlog setting add MaxAggregationInterval (#22098)
watany-dev Sep 19, 2022
205e493
revert(init-templates): csharp and fsharp app init fails when path co…
iliapolo Sep 19, 2022
ce0f018
Merge branch 'main' into merge-back/2.42.1
mergify[bot] Sep 19, 2022
53fd0e6
chore(merge-back): 2.42.1 (#22128)
mergify[bot] Sep 19, 2022
6840bc3
chore: Updating the prlinter (#22113)
Naumel Sep 20, 2022
384ba2b
fix(cli): "EACCES: Permission denied" on 'cdk init' (#22111)
rix0rrr Sep 20, 2022
e860ffc
chore(rds): add mysql engine version 8.0.30 (#22114)
WinterYukky Sep 20, 2022
35b2806
fix(integ-tests): AwsApiCall Custom Resource length could be greater …
dontirun Sep 20, 2022
a4364ce
fix(api-gateway): SpecRestApi ignores disableExecuteApiEndpoint prope…
TheRealAmazonKendra Sep 20, 2022
291bf34
chore(pr-lint): provide output to user in comments (#22029)
TheRealAmazonKendra Sep 20, 2022
cfaf2ba
chore(pr-linter): use github-actions bot to write to PRs (#22152)
TheRealAmazonKendra Sep 20, 2022
9f0264c
docs(iam): hints at accountId as string type (#22149)
misterjacko Sep 21, 2022
ce59b6a
fix(s3-deployment): fails when `destinationKeyPrefix` is a token with…
iliapolo Sep 21, 2022
edfd3e2
chore: introduce github merit badger workflow (#21898)
kaizencc Sep 21, 2022
fbb941f
feat(stepfunctions-tasks): additional IAM statements for AWS SDK serv…
jogold Sep 21, 2022
fd41cdd
chore: add bots to list of ignore-usernames (#22171)
scanlonp Sep 21, 2022
9726e8f
feat(cfnspec): cloudformation spec v89.0.0 (#22105)
aws-cdk-automation Sep 21, 2022
ee83650
chore(release): 2.43.0
Sep 21, 2022
89ebd94
Update CHANGELOG.v2.md
iliapolo Sep 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(cli): Lambda hotswap fails if environment contains tokens (#22099)
closes #22088 

We always need to use `evaluateCfnTemplate.evaluateCfnExpression` when a variable to be used in hotswap may contain tokens.

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
tmokmss authored Sep 19, 2022
commit 8280709219d95ac4bd76e21bfe8214a02afaa413
9 changes: 5 additions & 4 deletions packages/aws-cdk/lib/api/hotswap/lambda-functions.ts
Original file line number Diff line number Diff line change
@@ -164,9 +164,10 @@ async function isLambdaFunctionCodeOnlyChange(
*/
const tagUpdates: { [tag: string]: string | TagDeletion } = {};
if (updatedProp?.isDifferent) {
updatedProp.newValue.forEach((tag: CfnDiffTagValue) => {
tagUpdates[tag.Key] = tag.Value;
const tasks = updatedProp.newValue.map(async (tag: CfnDiffTagValue) => {
tagUpdates[tag.Key] = await evaluateCfnTemplate.evaluateCfnExpression(tag.Value);
});
await Promise.all(tasks);

updatedProp.oldValue.forEach((tag: CfnDiffTagValue) => {
if (tagUpdates[tag.Key] === undefined) {
@@ -178,10 +179,10 @@ async function isLambdaFunctionCodeOnlyChange(
}
break;
case 'Description':
description = updatedProp.newValue;
description = await evaluateCfnTemplate.evaluateCfnExpression(updatedProp.newValue);
break;
case 'Environment':
environment = updatedProp.newValue;
environment = await evaluateCfnTemplate.evaluateCfnExpression(updatedProp.newValue);
break;
default:
return ChangeHotswapImpact.REQUIRES_FULL_DEPLOYMENT;
Original file line number Diff line number Diff line change
@@ -905,3 +905,127 @@ test('calls both updateLambdaCode() and updateLambdaConfiguration() API when it
S3Key: 'new-key',
});
});

test('Lambda hotswap works properly with changes of environment variables, description, tags with tokens', async () => {
// GIVEN
setup.setCurrentCfnStackTemplate({
Resources: {
EventBus: {
Type: 'AWS::Events::EventBus',
Properties: {
Name: 'my-event-bus',
},
},
Func: {
Type: 'AWS::Lambda::Function',
Properties: {
Code: {
S3Bucket: 's3-bucket',
S3Key: 's3-key',
},
FunctionName: 'my-function',
Environment: {
Variables: {
token: { 'Fn::GetAtt': ['EventBus', 'Arn'] },
literal: 'oldValue',
},
},
Description: {
'Fn::Join': ['', [
'oldValue',
{ 'Fn::GetAtt': ['EventBus', 'Arn'] },
]],
},
Tags: [
{
Key: 'token',
Value: { 'Fn::GetAtt': ['EventBus', 'Arn'] },
},
{
Key: 'literal',
Value: 'oldValue',
},
],
},
Metadata: {
'aws:asset:path': 'asset-path',
},
},
},
});

setup.pushStackResourceSummaries(
setup.stackSummaryOf('EventBus', 'AWS::Events::EventBus', 'my-event-bus'),
);

const cdkStackArtifact = setup.cdkStackArtifactOf({
template: {
Resources: {
EventBus: {
Type: 'AWS::Events::EventBus',
Properties: {
Name: 'my-event-bus',
},
},
Func: {
Type: 'AWS::Lambda::Function',
Properties: {
Code: {
S3Bucket: 's3-bucket',
S3Key: 's3-key',
},
FunctionName: 'my-function',
Environment: {
Variables: {
token: { 'Fn::GetAtt': ['EventBus', 'Arn'] },
literal: 'newValue',
},
},
Description: {
'Fn::Join': ['', [
'newValue',
{ 'Fn::GetAtt': ['EventBus', 'Arn'] },
]],
},
Tags: [
{
Key: 'token',
Value: { 'Fn::GetAtt': ['EventBus', 'Arn'] },
},
{
Key: 'literal',
Value: 'newValue',
},
],
},
Metadata: {
'aws:asset:path': 'asset-path',
},
},
},
},
});

// WHEN
const deployStackResult = await hotswapMockSdkProvider.tryHotswapDeployment(cdkStackArtifact);

// THEN
expect(deployStackResult).not.toBeUndefined();
expect(mockUpdateLambdaConfiguration).toHaveBeenCalledWith({
FunctionName: 'my-function',
Environment: {
Variables: {
token: 'arn:aws:events:here:123456789012:event-bus/my-event-bus',
literal: 'newValue',
},
},
Description: 'newValuearn:aws:events:here:123456789012:event-bus/my-event-bus',
});
expect(mockTagResource).toHaveBeenCalledWith({
Resource: 'arn:aws:lambda:here:123456789012:function:my-function',
Tags: {
token: 'arn:aws:events:here:123456789012:event-bus/my-event-bus',
literal: 'newValue',
},
});
});