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-python): bundle asset files correctly #18335

Merged
merged 6 commits into from
Jan 10, 2022

Conversation

setu4993
Copy link
Contributor

Asset files are incorrectly being bundled under the asset-input directory instead of the root of the bundle.

To also copy over hidden files (#18306 (comment)), I switched from using -R to -a based on what I found on SO and the man page. (-a is equivalent to -dR.)

Fixes #18301 and @chrispykim's comment: #18082 (comment).


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 Jan 10, 2022

@setu4993
Copy link
Contributor Author

cc @njlynch

@setu4993
Copy link
Contributor Author

setu4993 commented Jan 10, 2022

I tested this locally in a Docker container and it bundles correctly for me. I'm not very familiar with how to check the contents of the bundling directory, so not sure how to add a test for it. I think it makes sense to get a release out that fixes this ASAP and then add a test later.

Never mind, I figured out how to add those tests and added them. Also added assertions for checking if hidden files get copied over (they do).

otaviomacedo
otaviomacedo previously approved these changes Jan 10, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 10, 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).

Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

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

Do we have a reproducible example for what's still breaking for people? I worry we're throwing darts at the map (or flags on the CLI) and hoping it will fix it without truly understanding the root cause.

@@ -87,7 +87,7 @@ export class Bundling implements CdkBundlingOptions {
if (packaging.dependenciesFile) {
bundlingCommands.push(`python -m pip install -r ${DependenciesFile.PIP} -t ${options.outputDir}`);
}
bundlingCommands.push(`cp -R ${options.inputDir}/ ${options.outputDir}`);
bundlingCommands.push(`cp -a ${options.inputDir}/* ${options.outputDir}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Including the * still drops hidden files. This needs to be removed.

Suggested change
bundlingCommands.push(`cp -a ${options.inputDir}/* ${options.outputDir}`);
bundlingCommands.push(`cp -a ${options.inputDir}/ ${options.outputDir}`);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Urm, I added a validation for it within the test, which passes.

@otaviomacedo otaviomacedo dismissed their stale review January 10, 2022 13:37

Verification needed

@mergify mergify bot dismissed njlynch’s stale review January 10, 2022 14:37

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Jan 10, 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).

@setu4993
Copy link
Contributor Author

Do we have a reproducible example for what's still breaking for people? I worry we're throwing darts at the map (or flags on the CLI) and hoping it will fix it without truly understanding the root cause.

That's what I added assertions to validate. I'm confident those would fail for what's currently on the release versions because it would include an extra layer in between.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit 3822c85 into aws:master Jan 10, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 10, 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).

@setu4993 setu4993 deleted the fix/lambda-python/bundling branch January 10, 2022 19:23
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Asset files are incorrectly being bundled under the `asset-input` directory instead of the root of the bundle.

To also copy over hidden files (aws#18306 (comment)), I switched from using `-R` to `-a` based on what I found on [SO](https://stackoverflow.com/a/13020113) and the [man page](https://linux.die.net/man/1/cp). (`-a` is equivalent to `-dR`.)

Fixes aws#18301 and @chrispykim's comment: aws#18082 (comment).

----

*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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

‼️ (aws-lambda-python): SAM - CDK integration is broken in CDK V2.4.0
5 participants