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

feat(lambda-python): support build args (#12949) #13938

Closed
wants to merge 4 commits into from

Conversation

rirze
Copy link

@rirze rirze commented Apr 1, 2021

Add support for passing build arguments when building the bundling
image.

Closes #12949


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 Apr 1, 2021

@rirze
Copy link
Author

rirze commented Apr 1, 2021

If possible, I'd like some help in adding support for passing in Docker environment variables for both PythonFunction and PythonLayerVersion. I tried taking a look at how it was implemented in lambda-nodejs but my Typescript comprehension wasn't strong enough to port over that functionality to this module.

eladb
eladb previously requested changes Apr 1, 2021
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Did you consider exposing a bundling option (like in NodeJsFunction) which already allows specifying buildArgs.


**Lambda with custom Docker Build Time Variables**

Use the `build_args` parameter to pass build arguments when building the bundling image:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Use the `build_args` parameter to pass build arguments when building the bundling image:
Use the `buildArgs` parameter to pass build arguments when building the bundling image:

*
* @default - no build arguments are passed
*/
readonly buildArgs?: { [key:string] : string };
Copy link
Contributor

Choose a reason for hiding this comment

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

Stylistic:

Suggested change
readonly buildArgs?: { [key:string] : string };
readonly buildArgs?: { [key:string]: string };

@rirze
Copy link
Author

rirze commented Apr 1, 2021

I did consider creating a bundling options class, but after looking at its implementation in aws-lambda-nodejs/bundling.ts, I couldn't separate what was essential to Docker and what was specific to Typescript bundling (esbuild).

If desired, I could try my hand at exposing a Bundling class for this module and we could iteratively refine it. I'd imagine this would require a few rounds of feedback.

@mergify mergify bot dismissed eladb’s stale review April 1, 2021 16:30

Pull request has been modified.

@eladb
Copy link
Contributor

eladb commented Apr 1, 2021

@rirze there is already a BundlingOptions struct, why not reuse that? (like NodeJsFunction does)

@jogold any chance you can work with @rirze to align those APIs?

@rirze
Copy link
Author

rirze commented Apr 1, 2021

Hmm, I think I was confused because I assumed PythonFunction would need its own Bundling class like it does in NodeJsFunction (Bundling implements cdk.BundlingOptions). But looking it more, it seems like most of the logic there is related to esbuild. So making sure I understand correctly, passing in a cdk.BundlingOptions should be sufficient for PythonFunction/PythonLayerVersion, correct?

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@jogold
Copy link
Contributor

jogold commented Apr 20, 2021

We currently have the following API for the NodejsFunction:

I think we can do the same here.

@eladb
Copy link
Contributor

eladb commented May 2, 2021

@rirze I am closing this PR for now. Feel free to re-open when ready to continue :-)

@eladb eladb closed this May 2, 2021
setu4993 added a commit to setu4993/aws-cdk that referenced this pull request Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lambda-python: Allow passing build args to Docker in PythonFunction
4 participants