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

fix(lambda): Validate Lambda "functionName" parameter #17970

Merged
merged 8 commits into from
Feb 17, 2022
Merged

fix(lambda): Validate Lambda "functionName" parameter #17970

merged 8 commits into from
Feb 17, 2022

Conversation

Dzhuneyt
Copy link
Contributor

@Dzhuneyt Dzhuneyt commented Dec 11, 2021

Closes #13264


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

@gitpod-io
Copy link

gitpod-io bot commented Dec 11, 2021

@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Dec 11, 2021
@Dzhuneyt Dzhuneyt changed the title feat: Validate Lambda "functionName" parameter fix: Validate Lambda "functionName" parameter Dec 11, 2021
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Thanks for opening the PR! A couple of comments, and I agree with @jumic in that we need to consider tokens as well.

packages/@aws-cdk/aws-lambda/lib/function.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/test/function.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/lib/function.ts Outdated Show resolved Hide resolved
@kaizencc kaizencc changed the title fix: Validate Lambda "functionName" parameter fix(lambda): Validate Lambda "functionName" parameter Dec 14, 2021
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

hmmm not sure why the linter didn't find these but I like my spaces :)

packages/@aws-cdk/aws-lambda/test/function.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/test/function.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/test/function.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/test/function.test.ts Outdated Show resolved Hide resolved
@kaizencc kaizencc added effort/small Small work item – less than a day of effort p2 labels Jan 24, 2022
@kaizencc
Copy link
Contributor

@Dzhuneyt, it's been a while since there was any action on this PR. Are you still available to work on this?

@Dzhuneyt
Copy link
Contributor Author

Yeah. Sorry, I was on vacation.

@mergify mergify bot dismissed kaizencc’s stale review January 30, 2022 21:13

Pull request has been modified.

@Dzhuneyt
Copy link
Contributor Author

@kaizen3031593 @jumic addressed your comments above. Let me know if you see anything else that can be improved.

Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

almost there @Dzhuneyt -- just a question about the allowed length of a lambda function name.

@@ -690,6 +690,15 @@ export class Function extends FunctionBase {
}
this._architecture = props.architecture ?? (props.architectures && props.architectures[0]);

if (props.functionName && !Token.isUnresolved(props.functionName)) {
if (props.functionName.length > 140) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this says that the length cannot be greater than 64 characters. Where are you gettintg the 140 from?

Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps the 140 comes from here? @Dzhuneyt do you think you can help investigate the correct length here? #18795

Copy link
Contributor

Choose a reason for hiding this comment

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

I've confirmed that the number is 64 here. Going to update this PR accordingly.

new lambda.Function(stack, `foo${invalidChar}`, {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_10_X,
Copy link
Contributor

Choose a reason for hiding this comment

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

this runtime has an end-of-life set for 2/14/22. lets use Node 12 or 14.

new lambda.Function(stack, 'foo', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_10_X,
Copy link
Contributor

Choose a reason for hiding this comment

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

here too

@mergify mergify bot dismissed kaizencc’s stale review February 17, 2022 20:57

Pull request has been modified.

Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Thanks for getting this started @Dzhuneyt, just made a few modifications to get this across the finish line.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify
Copy link
Contributor

mergify bot commented Feb 17, 2022

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).

@mergify mergify bot merged commit a416a2d into aws:master Feb 17, 2022
@Dzhuneyt Dzhuneyt deleted the dzhuneyt/issue-13264 branch February 18, 2022 12:26
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Closes aws#13264

----

*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
@aws-cdk/aws-lambda Related to AWS Lambda effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-lambda): Validate Lambda functionName
4 participants