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

core: support specifying included files for Code.from_asset #26107

Open
2 tasks
rittneje opened this issue Jun 24, 2023 · 6 comments
Open
2 tasks

core: support specifying included files for Code.from_asset #26107

rittneje opened this issue Jun 24, 2023 · 6 comments
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

@rittneje
Copy link

rittneje commented Jun 24, 2023

Describe the feature

Add a property to Code.from_asset to indicate which particular files within the path should be included. If this property is present, only files matching the pattern will be considered. It is an error to specify this property if the path does not describe a directory.

Use Case

We have a bunch of Go lambda functions in one repository. We can easily compile multiple of them in parallel with go build -o $DIR my-module/cmd/.... However, this places all the binaries together in one directory. We would like to be able to reference this directory in Code.from_assets and filter it to only the particular binary name that goes with the Lambda function in question.

Currently we have to manually arrange for each binary to be in its own folder, which is really annoying.

Proposed Solution

No response

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

Environment details (OS name and version, etc.)

Alpine 3.18

@rittneje rittneje added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jun 24, 2023
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Jun 24, 2023
@pahud
Copy link
Contributor

pahud commented Jun 26, 2023

Thanks for your use case sharing.

@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
@go-to-k
Copy link
Contributor

go-to-k commented Jul 13, 2023

@pahud

Hi, Pahud!

I have a question for you on this issue.
This issue's title is about aws_lambda, but the actual asset processing is done in the core module, so I think it should be done in core, what do you think?

Specifically, I am thinking of the following approach.

  • Add an include parameter to interface FileOptions with exclude.
  • Check for matching include along with ignores (actually exclude) in copyDirectory, where the actual file search is done.

I haven't submitted a PR yet, but I've implemented it as a trial. I'll let you know what you think and make a decision.

main...go-to-k:aws-cdk:feat/fs-copy-include-files

@pahud pahud changed the title aws_lambda: support specifying included files for Code.from_asset core: support specifying included files for Code.from_asset Jul 14, 2023
@pahud
Copy link
Contributor

pahud commented Jul 14, 2023

@go-to-k Yes this sounds like a good idea! Feel free to submit your PR draft for that, the maintainers would be happy to review your PR.

@go-to-k
Copy link
Contributor

go-to-k commented Jul 14, 2023

@pahud

Thank you! I will submit PR!

@go-to-k
Copy link
Contributor

go-to-k commented Jul 22, 2023

It was mentioned that the exclude property with a negation pattern could be used instead of using the include property, so the PR was closed.

#26365 (comment)

@go-to-k
Copy link
Contributor

go-to-k commented Jul 22, 2023

I also submitted the PR for the docs of exclude property using a negation.

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.

3 participants