Skip to content

feat(cli): support hotswapping Lambda function tags - #17818

Merged
mergify[bot] merged 5 commits into
aws:masterfrom
offbyone:feature-hotswap-tags
Dec 17, 2021
Merged

mergify[bot] merged 5 commits into
aws:masterfrom
offbyone:feature-hotswap-tags

Conversation

@offbyone

@offbyone offbyone commented Dec 2, 2021 •

Copy link
Copy Markdown
Contributor

Fixes #17664


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io

gitpod-io Bot commented Dec 2, 2021

Copy link
Copy Markdown

@github-actions github-actions Bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Dec 2, 2021
@mergify

mergify Bot commented Dec 2, 2021

Copy link
Copy Markdown
Contributor

Title does not follow the guidelines of Conventional Commits. Please adjust title before merge.

@offbyone offbyone changed the title Hotswap support for tags on Lambda functions feat(cli): Hotswap support for tags on Lambda functions Dec 2, 2021
@github-actions github-actions Bot added the package/tools Related to AWS CDK Tools or CLI label Dec 2, 2021
@offbyone
offbyone force-pushed the feature-hotswap-tags branch 3 times, most recently from 9bb95cb to 03b8775 Compare December 3, 2021 16:39
@kaizencc kaizencc removed the @aws-cdk/aws-lambda Related to AWS Lambda label Dec 3, 2021
@kaizencc kaizencc assigned skinny85 and unassigned rix0rrr and kaizencc Dec 3, 2021
@offbyone

offbyone commented Dec 3, 2021

Copy link
Copy Markdown
Contributor Author

This will need at least one more revision before it's ready; hold off on review til EOD today, at least, please.

@skinny85

skinny85 commented Dec 3, 2021 •

Copy link
Copy Markdown
Contributor

This will need at least one more revision before it's ready; hold off on review til EOD today, at least, please.

Sound good @offbyone, let us know when you consider this ready for review!

@offbyone
offbyone force-pushed the feature-hotswap-tags branch from 03b8775 to b280bce Compare December 3, 2021 23:26
@offbyone

offbyone commented Dec 3, 2021

Copy link
Copy Markdown
Contributor Author

I'd call it ready for review. Despite our discussion about the asset tags in the metadata, I was unable to avoid removing that check. I believe the property checks in here are sufficient safety.

@skinny85 skinny85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @offbyone! A few comments, but nothing major.

Comment thread packages/aws-cdk/jest.config.js Resolved
Comment thread packages/aws-cdk/jest.config.js Resolved
Comment thread packages/aws-cdk/jest.config.js Resolved
Comment thread packages/aws-cdk/test/assets.test.ts Resolved
@skinny85

skinny85 commented Dec 6, 2021

Copy link
Copy Markdown
Contributor

BTW, the build is failing with:

aws-cdk: FAIL test/api/exec.test.ts
aws-cdk:   â—� Test suite failed to run
aws-cdk:     TypeError: Cannot read property 'DEFAULT' of undefined
aws-cdk:       14 | };
aws-cdk:       15 |
aws-cdk:     > 16 | export let logLevel = LogLevel.DEFAULT;
aws-cdk:          |                                ^
aws-cdk:       17 |
aws-cdk:       18 | export function setLogLevel(newLogLevel: LogLevel) {
aws-cdk:       19 |   logLevel = newLogLevel;
aws-cdk:       at Object.<anonymous> (lib/logging.ts:16:32)
aws-cdk:       at Object.<anonymous> (lib/api/cxapp/exec.ts:6:1)

So, you might have to revert your changes to the test setup.

@offbyone
offbyone force-pushed the feature-hotswap-tags branch from 09799b2 to 8188ffe Compare December 8, 2021 22:16
@mergify
mergify Bot dismissed skinny85’s stale review December 8, 2021 22:17

Pull request has been modified.

@offbyone
offbyone force-pushed the feature-hotswap-tags branch 2 times, most recently from 826a7f6 to cc18ae6 Compare December 8, 2021 23:35
Implements aws#17664

For Lambda functions, identify tag changes in the CF diff, and attach
tag removal / set operations for all tags that changed.
@offbyone
offbyone force-pushed the feature-hotswap-tags branch from cc18ae6 to 71ef767 Compare December 9, 2021 00:53
@offbyone
offbyone marked this pull request as ready for review December 9, 2021 16:22

@skinny85 skinny85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall! Some minor comments, mainly around formatting.

@rix0rrr do you mind taking a quick look at the test setup changes? Thanks!

*/
public readonly propertyUpdates: { [key: string]: cfn_diff.PropertyDifference<any> };


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert this one:

Suggested change

const functionArn = await evaluateCfnTemplate.evaluateCfnExpression({
'Fn::Sub': 'arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:' + functionName,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's kill this empty line (I'm actually surprised the linter didn't flag this one):

Suggested change

Comment on lines +67 to +68
let code: LambdaFunctionCode | void = undefined;
let tags: LambdaFunctionTags | void = undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let code: LambdaFunctionCode | void = undefined;
let tags: LambdaFunctionTags | void = undefined;
let code: LambdaFunctionCode | undefined = undefined;
let tags: LambdaFunctionTags | undefined = undefined;

Comment on lines +116 to +118
tags = {
tagUpdates,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tags = {
tagUpdates,
};
tags = { tagUpdates };

Comment on lines +153 to +154
readonly code: LambdaFunctionCode | void,
readonly tags: LambdaFunctionTags | void,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
readonly code: LambdaFunctionCode | void,
readonly tags: LambdaFunctionTags | void,
readonly code?: LambdaFunctionCode;
readonly tags?: LambdaFunctionTags;

Comment on lines +183 to +186
// It's really unfortunate, but Lambda allows function _names_ for code
// updates, but we need the function ARN if we're managing tags. We also
// can't assume we'll get it from the preceding code update, since there
// might not _be_ a code update.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this comment anymore I think:

Suggested change
// It's really unfortunate, but Lambda allows function _names_ for code
// updates, but we need the function ARN if we're managing tags. We also
// can't assume we'll get it from the preceding code update, since there
// might not _be_ a code update.

}

// run all of our updates in parallel
await Promise.all(operations);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await Promise.all(operations);
return Promise.all(operations);

Comment thread packages/aws-cdk/lib/logging.ts Outdated
DEBUG = 1,
/** Extremely verbose */
TRACE = 2
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert this move too (unless there's a good reason for it...?).

skinny85
skinny85 previously approved these changes Dec 17, 2021
@mergify
mergify Bot dismissed skinny85’s stale review December 17, 2021 02:12

Pull request has been modified.

@skinny85 skinny85 changed the title feat(cli): Hotswap support for tags on Lambda functions feat(cli): support hotswapping Lambda function tags Dec 17, 2021
@skinny85 skinny85 added the pr-linter/exempt-readme The PR linter will not require README changes label Dec 17, 2021
@mergify

mergify Bot commented Dec 17, 2021

Copy link
Copy Markdown
Contributor

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation

Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: e10caef
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
mergify Bot merged commit e4485f4 into aws:master Dec 17, 2021
@mergify

mergify Bot commented Dec 17, 2021

Copy link
Copy Markdown
Contributor

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Fixes aws#17664 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
ali-n4i pushed a commit to ali-n4i/aws-cdk that referenced this pull request Jul 29, 2026
Fixes aws#17664 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package/tools Related to AWS CDK Tools or CLI pr-linter/exempt-readme The PR linter will not require README changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(cli): Hotswap support for resource tags

5 participants