aws-cdk-rfcs icon indicating copy to clipboard operation
aws-cdk-rfcs copied to clipboard

PythonFunction additional build options

Open CoreOxide opened this issue 1 year ago • 6 comments

Description

Today, CDK deploy uses docker as it's backend to collect and install dependencies. I'm proposing a way to do that without using Docker. It will also allow building for different OS targets and Lambda runtimes.

There are 2 ways to build without docker:

  • Using native dependency resolution using PIP flags.
  • Using AWS CloudShell (most useful for building Lambda Layers).

As @evgenyka suggested in #579, I want to inherit from PythonFunction and intorucde building backend options to the new class.

Looking for your approval before going forward.

Roles

Role User
Proposed by @CoreOxide
Author(s) @alias, @alias, @alias
API Bar Raiser @alias
Stakeholders @alias, @alias, @alias

See RFC Process for details

Workflow

  • [x] Tracking issue created (label: status/proposed)
  • [ ] API bar raiser assigned (ping us at #aws-cdk-rfcs if needed)
  • [ ] Kick off meeting
  • [ ] RFC pull request submitted (label: status/review)
  • [ ] Community reach out (via Slack and/or Twitter)
  • [ ] API signed-off (label status/api-approved applied to pull request)
  • [ ] Final comments period (label: status/final-comments-period)
  • [ ] Approved and merged (label: status/approved)
  • [ ] Execution plan submitted (label: status/planning)
  • [ ] Plan approved and merged (label: status/implementing)
  • [ ] Implementation complete (label: status/done)

Author is responsible to progress the RFC according to this checklist, and apply the relevant labels to this issue so that the RFC table in README gets updated.

CoreOxide avatar Jan 02 '24 08:01 CoreOxide

nice one, would really help me to remove docker dependency in my open source project that use cdk and Lambda. @evgenyka please approve this approach :)

ran-isenberg avatar Jan 02 '24 08:01 ran-isenberg

The aws-cdk-lib.aws_lambda.Function construct allows to perform local bundling, see the "Building locally" section in Building, bundling, and deploying applications with the AWS CDK blog post.

@evgenyka is there a reason aws-cdk.aws-lambda-python-alpha.PythonFunction can't support local bundling?

alexpulver avatar Jan 09 '24 20:01 alexpulver

@evgenyka bump? :)

ran-isenberg avatar Jan 28 '24 09:01 ran-isenberg

@evgenyka pls advise 👍

CoreOxide avatar Feb 25 '24 07:02 CoreOxide

@alexpulver Local bundling supported in Go and NodeJS (esbuild) at the moment, @CoreOxide similar to: https://github.com/1davidmichael/cdk-local-bundling-example? You can get your PR against https://github.com/aws/aws-cdk/issues/18290

evgenyka avatar Feb 26 '24 07:02 evgenyka

@evgenyka it is similar, however my solution is more robust. my code will allow building for Lambda natively from MacOS and Windows, installing the correct packages for Linux instead of the OS you're running on (which is what will happen here -> https://github.com/1davidmichael/cdk-local-bundling-example).

I will open a PR under https://github.com/aws/aws-cdk/issues/18290.

CoreOxide avatar Feb 26 '24 13:02 CoreOxide