Skip to content

Commit

Permalink
feat(lambda): allow running a build file (aws#30196)
Browse files Browse the repository at this point in the history
### Issue # (if applicable)

Closes aws#18470

### Reason for this change

This allows customers to execute an arbitrary build script as part of cdk synth, which will enable customer to use esbuild plugins. The rationale for this decision is given the issue that is linked above.

### Description of changes

1. Expose the code field on the `aws-lambda-nodejs` construct, so that customers can specify code in ways other than bundling, which was the default and abstracted away from customers before this change.
2. Add a new static method on Code, namely `Code.fromCustomCommand`. This method takes in the commands to run an arbitrary script during cdk synthesis that the customer provides. The customer also provides the location of the output from the buildscript. Then this output is supplied to a lambda function.

### Description of how you validated changes

manual testing (involving inspecting output in the AWS Lambda console and invoking the function), integration tests, and full unit test coverage of new changes.

### Checklist
- [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
bergjaak authored and Dahlberg Victor committed Jun 10, 2024
1 parent d920078 commit 686f8b6
Show file tree
Hide file tree
Showing 22 changed files with 32,928 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -euo pipefail

directoryOfThisScript=$(cd $(dirname $0) && pwd)
echo "directoryOfThisScript: $directoryOfThisScript"
cp "$directoryOfThisScript/custom_command_handler.js" "$directoryOfThisScript/../custom_command_output/mylambdafile.js"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function handler() {
return 'NICE';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Code gets placed in here from the integ.specifycode.ts test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 686f8b6

Please sign in to comment.