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
Once this is done, install [Zig](https://ziglang.org/) using the instructions in their [installation guide](https://ziglang.org/learn/getting-started/#installing-zig), and install `cargo-zigbuild`:
57
+
Once this is done, install `cargo-lambda`:
58
58
59
59
```bash
60
-
cargo install cargo-zigbuild
60
+
cargo install cargo-lambda
61
61
```
62
62
63
+
This Cargo subcommand will give you the option to install [Zig](https://ziglang.org/) to use as the linker. You can also install [Zig](https://ziglang.org/) using the instructions in their [installation guide](https://ziglang.org/learn/getting-started/#installing-zig).
64
+
63
65
#### 1.2. Build your Lambda functions
64
66
65
67
__Amazon Linux 2__
@@ -68,7 +70,7 @@ We recommend you to use Amazon Linux 2 runtimes (such as `provided.al2`) as much
68
70
69
71
```bash
70
72
# Note: replace "aarch64" with "x86_64" if you are building for x86_64
For [a custom runtime](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html), AWS Lambda looks for an executable called `bootstrap` in the deployment package zip. Rename the generated executable to `bootstrap` and add it to a zip archive.
88
90
89
-
__Note__: Depending on the target you used above, you'll find the provided basic executable under the corresponding directory. For example, if you are building the aarch64-unknown-linux-gnu as your target, it will be under `./target/aarch64-unknown-linux-gnu/release/`.
91
+
You can find the `bootstrap` binary for your function under the `target/lambda` directory.
90
92
91
93
#### 2.1. Deploying with the AWS CLI
92
94
93
95
First, you will need to create a ZIP archive of your Lambda function. For example, if you are using the `basic` example and aarch64-unknown-linux-gnu as your target, you can run:
94
96
95
97
```bash
96
-
cp ./target/aarch64-unknown-linux-gnu/release/examples/basic ./bootstrap && zip lambda.zip bootstrap && rm bootstrap
98
+
zip -j lambda.zip target/lambda/basic/bootstrap
97
99
```
98
100
99
101
Now that we have a deployment package (`lambda.zip`), we can use the [AWS CLI](https://aws.amazon.com/cli/) to create a new Lambda function. Make sure to replace the execution role with an existing role in your account!
@@ -141,21 +143,14 @@ Resources:
141
143
Handler: bootstrap
142
144
Runtime: provided.al2
143
145
Timeout: 5
144
-
CodeUri: build/
146
+
CodeUri: target/lambda/basic/
145
147
146
148
Outputs:
147
149
FunctionName:
148
150
Value: !Ref HelloWorldFunction
149
151
Description: Name of the Lambda function
150
152
```
151
153
152
-
After building your function, you will also need to store the binary as `bootstrap` in a dedicated directory for that function (e.g. `build/bootstrap`):
0 commit comments