You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Use Cargo Lambda
Remove directory structure generation, since that tools gives you
that for free.
Signed-off-by: David Calavera <david.calavera@gmail.com>
* Update name references
Signed-off-by: David Calavera <david.calavera@gmail.com>
@@ -120,9 +105,7 @@ All other properties of `lambda.Function` are supported, see also the [AWS Lambd
120
105
121
106
When bundling the code, the `RustFunction` runs the following steps in order:
122
107
123
-
- First it runs `cargo zigbuild`, and passes in the `--release` and `--target` flags, so it compiles for a Lambda environment - which defaults to the **aarch64-unknown-linux-gnu** target, as mentioned above. Note that _zigbuild_ does initially confirm that the Rust code can compile.
124
-
125
-
- Next, it copies the release app binary from the `target/` folder to a file named `bootstrap`, which the Lambda custom runtime environment looks for. It adds this new file under the _build directory_, which defaults to a `.build/` folder under the directory where `cdk` was invoked.
108
+
- First it runs `cargo lambda`, and passes in the `--release` and `--target` flags, so it compiles for a Lambda environment - which defaults to the **aarch64-unknown-linux-gnu** target, as mentioned above. Note that _cargo lambda_ does initially confirm that the Rust code can compile.
126
109
127
110
- The directory path to the executable is then passed in to `lambda.Code.fromAsset`, which creates a _zip file_ from the release binary asset.
128
111
@@ -132,7 +115,7 @@ If you instead prefer to use [Docker] and [`cross`] for deployment, as outlined
132
115
in the [official AWS docs], you can install and use the [latest `v0.x`] release instead:
133
116
134
117
```shell
135
-
$ npm i rust.aws-cdk-lambda@0.4.0
118
+
$ npm i rust.aws-cdk-lambda@0.4.0 --save-optional
136
119
```
137
120
138
121
[docker]: https://www.docker.com/get-started
@@ -294,8 +277,8 @@ Below lists some commonly used properties you can pass in to the `RustFunction`
294
277
| `setupLogging` | Determines whether we want to set up [library logging](https://rust-lang-nursery.github.io/rust-cookbook/development_tools/debugging/config_log.html) - i.e. set the `RUST_LOG` environment variable - for the lambda function.<br><br>The format defaults to `warn,module_name=debug`, which means that the default log level is `warn`, and the executable or library's log level is `debug`. |
295
278
||
296
279
|`features`| A list of features to activate when compiling Rust code. These must also be added to the `Cargo.toml` file. |
297
-
|`buildEnvironment`| Key-value pairs that are passed in at compile time, i.e. to `cargo build` or `cargo zigbuild`. This differs from `environment`, which determines the environment variables which are set on the AWS Lambda functionitself.|
298
-
|`extraBuildArgs`| Additional arguments that are passed in at build time to `cargo zigbuild`. For example, [`--all-features`]. |
280
+
|`buildEnvironment`| Key-value pairs that are passed in at compile time, i.e. to `cargo build` or `cargo lambda`. This differs from `environment`, which determines the environment variables which are set on the AWS Lambda functionitself.|
281
+
|`extraBuildArgs`| Additional arguments that are passed in at build time to `cargo lambda`. For example, [`--all-features`]. |
299
282
300
283
## Settings
301
284
@@ -314,5 +297,5 @@ Below are some useful _global_ defaults which can be set for all Rust Lambda Fun
314
297
|`MODULE_LOG_LEVEL`| Log Level for a module (i.e. the executable). Note that this value is only used when `RustFunctionProps.setupLogging` is enabled. Defaults to `debug`. |
315
298
|`WORKSPACE_DIR`| Sets the root workspace directory. By default, the workspace directory is assumed to be the directory where `cdk` was invoked.<br><br>This directory should contain at the minimum a `Cargo.toml` file which defines the workspace members. |
316
299
|`FEATURES`| A list of features to activate when compiling Rust code. These must also be added to the `Cargo.toml` file. |
317
-
|`BUILD_ENVIRONMENT`| Key-value pairs that are passed in at compile time, i.e. to `cargo build` or `cargo zigbuild`. This differs from `environment`, which determines the environment variables which are set on the AWS Lambda functionitself.|
318
-
|`EXTRA_BUILD_ARGS`| Additional arguments that are passed in at build time to both `cargo zigbuild`. For example, [`--all-features`]. |
300
+
|`BUILD_ENVIRONMENT`| Key-value pairs that are passed in at compile time, i.e. to `cargo build` or `cargo lambda`. This differs from `environment`, which determines the environment variables which are set on the AWS Lambda functionitself.|
301
+
|`EXTRA_BUILD_ARGS`| Additional arguments that are passed in at build time to both `cargo lambda`. For example, [`--all-features`]. |
Copy file name to clipboardExpand all lines: cdk-examples/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,12 +17,12 @@ cd my-app
17
17
npm i
18
18
```
19
19
20
-
Next, ensure that you have [`cargo-zigbuild`](https://github.com/messense/cargo-zigbuild) installed. You will need this to cross-compile Rust code for deployment via `cdk`.
21
-
If you don't have `cargo-zigbuild` installed, refer to the [Getting Started](https://github.com/rnag/rust.aws-cdk-lambda#getting-started) section in docs for more info on getting set up.
20
+
Next, ensure that you have [`cargo-lambda`](https://crates.io/crates/cargo-lambda) installed. You will need this to cross-compile Rust code for deployment via `cdk`.
21
+
If you don't have `cargo-lambda` installed, refer to the [Getting Started](https://github.com/rnag/rust.aws-cdk-lambda#getting-started) section in docs for more info on getting set up.
22
22
23
23
Now you can deploy the app with `cdk`:
24
24
25
-
> Note: on an initial run, it may take a _really_ long time on the compilation step with `cargo-zigbuild`. In my case, it sometimes took up to _12 minutes_! But don't worry, any subsequent deployments should be overall faster.
25
+
> Note: on an initial run, it may take a _really_ long time on the compilation step with `cargo-lambda`. In my case, it sometimes took up to _12 minutes_! But don't worry, any subsequent deployments should be overall faster.
0 commit comments