See the AWS docs here for more information on creating Rust Lambdas.
- Docker Desktop is running
- LocalStack Pro auth token is set in the environment variable LOCALSTACK_AUTH_TOKEN
Create a file name .env-gdc-local and add the following to it:
export LOCALSTACK_AUTH_TOKEN=<your LocalStack auth token>
make start-localstack
OR
Run a GDC (generic dev container) in the root of the repo.
- Clone this GDC
- Run the GDC
<path to GDC>/run-dev-container.sh
- Connect to the GDC
docker exec -it rls-dev-1 bash -l
Building for lambda requires more libs be installed into the GDC to cross-compile the Rust binary.
Use the makefile target init-rust to install the necessary libs.
If you're running on a Mac and not in a GDC, you will have to put sudo
in front of this make command.
make init-rust
make all
Set the AWS_ACCT variable in the makefile to the account number of the AWS account you want to deploy to. AWS Account Number is defaulted to the LocalStack default account number. Setup a profile in your ~/.aws/credentials file with the necessary permissions to create a lambda function. To use a LocalStack profile, create it and set AWS_PROFILE like this LocalStack AWS Profile
If you are using LocalStack, set the AWS_PROFILE environment variable to the LocalStack profile. Otherwise, set it to the profile in your ~/.aws/credentials file for your live AWS account.
export AWS_PROFILE=localstack
make create-lambda-role
Assume a role with the necessary permissions to create a lambda function.
make create-lambda-function
In the Ubuntu dev container, you probably have to run this twice. There is some issue with Rust compilation on the Ubuntu dev container here. It doesn't happen on Mac and Windows.
make test
make delete-lambda