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

lambda: Updating The Lambda Architecture Properties with toString() methods #26117

Closed
1 of 2 tasks
lukey-aleios opened this issue Jun 26, 2023 · 4 comments · Fixed by #26145
Closed
1 of 2 tasks

lambda: Updating The Lambda Architecture Properties with toString() methods #26117

lukey-aleios opened this issue Jun 26, 2023 · 4 comments · Fixed by #26145
Labels
@aws-cdk/aws-lambda Related to AWS Lambda effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@lukey-aleios
Copy link
Contributor

Describe the feature

Updating The Lambda Properties with toString() methods

Use Case

We want to use effective error throwing using config properties, but they require a lot of code that could be decluttered if the properties have a toString method consistently (like there is on Runtime)

Proposed Solution

Add toString() methods to the Lambda Props

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.69.0

Environment details (OS name and version, etc.)

macOS Ventura - Version 13.3.1 (22E261)

@lukey-aleios lukey-aleios added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jun 26, 2023
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Jun 26, 2023
@pahud pahud changed the title (module name): (short issue description) lambda: Updating The Lambda Properties with toString() methods Jun 26, 2023
@pahud
Copy link
Contributor

pahud commented Jun 26, 2023

It's unclear to me about the advantages.

Can you share some code snippets to elaborate a little bit more on that?

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jun 26, 2023
@lukey-aleios
Copy link
Contributor Author

Hey Pahud!

We're building a wrapper around constructs (in this instance Lambda) and want to throw an error to tell what particular property is incorrect. Say I have this allowedConfig (the acceptable values for certain fields)
export const allowedConfig = { runtime: [Runtime.NODEJS_18_X], architecture: [Architecture.ARM_64], tracing: [Tracing.ACTIVE] as const, retryAttempts: [0, 1, 2] as const, };

But I create this Lamdba:

new MyLambda(this, 'HelloWorldLambda', { functionName: 'hello-world', architecture: Architecture.X86_64, tracing: Tracing.ACTIVE, entry: join(__dirname, 'handler.ts'), runtime: Runtime.NODEJS_18_X, retryAttempts: 2, });
And I'm throwing an error that would reference the allowedConfig like this:

Invalid architecture for Lambda function. Allowed architectures: ${allowedConfig.architecture.join( ', ', )},

I only see an [object bject] response in the error string instead of the actual value of allowed architectures. Here's the exact error

LambdaConfigurationError: Invalid architecture for Lambda function. Allowed architectures: [object Object].

The addition of a toString() method on the architecture parameter would alleviate this issue, and I was looking at potentially adding this to other fields that may be useful.

@lukey-aleios lukey-aleios changed the title lambda: Updating The Lambda Properties with toString() methods lambda: Updating The Lambda Architecture Properties with toString() methods Jun 28, 2023
@lukey-aleios
Copy link
Contributor Author

I've updated the title to just add a toString for the architecture, so this would require less work and solve my immediate issue

@mergify mergify bot closed this as completed in #26145 Jul 17, 2023
mergify bot pushed a commit that referenced this issue Jul 17, 2023
Add  toString to Lambda Architecture property

When throwing errors during synthesis, you can't see the architecture chosen for a lambda. Adding this toString method solves that

Closes #26117

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

colifran pushed a commit that referenced this issue Jul 17, 2023
Add  toString to Lambda Architecture property

When throwing errors during synthesis, you can't see the architecture chosen for a lambda. Adding this toString method solves that

Closes #26117

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
bmoffatt pushed a commit to bmoffatt/aws-cdk that referenced this issue Jul 29, 2023
Add  toString to Lambda Architecture property

When throwing errors during synthesis, you can't see the architecture chosen for a lambda. Adding this toString method solves that

Closes aws#26117

----

*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/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants