cargo-lambda


Namecargo-lambda JSON
Version 0.8.3 PyPI version JSON
download
home_pagehttps://github.com/cargo-lambda/cargo-lambda
SummaryCargo subcommand to work with AWS Lambda
upload_time2022-06-14 02:08:07
maintainerNone
docs_urlNone
authorNone
requires_python
licenseMIT
keywords cargo subcommand aws lambda
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cargo-lambda

[![crates.io][crate-image]][crate-link]
[![Build Status][build-image]][build-link]

cargo-lambda is a [Cargo](https://doc.rust-lang.org/cargo/) subcommand to help you work with AWS Lambda.

The [new](#new) subcommand creates a basic Rust package from a well defined template to help you start writing AWS Lambda functions in Rust.

The [build](#build) subcommand compiles AWS Lambda functions natively and produces artifacts which you can then [upload to AWS Lambda](#deploy) or use with other echosystem tools, like [SAM Cli](https://github.com/aws/aws-sam-cli) or the [AWS CDK](https://github.com/aws/aws-cdk).

The [watch](#watch) subcommand boots a development server that emulates interations with the AWS Lambda control plane. This subcommand also reloads your Rust code as you work on it.

The [invoke](#invoke) subcommand sends requests to the control plane emulator to test and debug interactions with your Lambda functions. This command can also be used to send requests to remote functions once deployed on AWS Lambda.

The [deploy](#deploy) subcommand uploads functions to AWS Lambda. You can use the same command to create new functions as well as update existent functions code.

## Installation

### With Homebrew (MacOS and Linux)

You can use [Homebrew](https://brew.sh/) to install cargo-lambda on MacOS and Linux. Run the following commands on your terminal to add our tap, and install cargo-lambda:

```
brew tap cargo-lambda/cargo-lambda
brew install cargo-lambda
```

### With Scoop (Windows)

You can use [Scoop](https://scoop.sh/) to install cargo-lambda on Windows. Run the following commands to add our bucket, and install cargo-lambda:

```
scoop bucket add cargo-lambda https://github.com/cargo-lambda/scoop-cargo-lambda
scoop install cargo-lambda/cargo-lambda
```

### With PyPI

You can also use [PyPI](https://pypi.org/) to install cargo-lambda:

```
pip install cargo-lambda
```

### Building from source

Install cargo-lambda on your host machine with Cargo itself:

```
cargo install cargo-lambda
```

⚠️ cargo-install compiles the binary in your system, which usually takes several minutes.

### Downloading a prebuit binary

Go to the [releases](https://github.com/cargo-lambda/cargo-lambda/releases) page, and download a pre-built binary for your specific platform.

## Usage

### New

The `new` command creates new Rust packages with a basic scheleton to help you start writing AWS Lambda functions with Rust. This command will create this package in a new sub-directory inside the directory where it's invoked. Run `cargo lambda new PACKAGE-NAME` to generate your new package.

This command uses templates packed as zip files, or from local directories. The [default template](https://github.com/cargo-lambda/default-template) supports HTTP Lambda functions, as well as functions that receive events defined in the [aws_lambda_events crate](https://crates.io/crates/aws-lambda-events). You can provide your own template using the `--template` flag.

The files `Cargo.toml`, `README.md`, and `src/main.rs` in the template are parsed with [Liquid](https://crates.io/crates/liquid) to dynamically render different files based on a series of global variables. You can see all the variables in [the source code](https://github.com/cargo-lambda/cargo-lambda/blob/main/crates/cargo-lambda-new/src/lib.rs#L167-L178).

After creating a new package, you can use the [build](#build) command described below to compile the source code.

### Build

Within a Rust project that includes a `Cargo.toml` file, run the `cargo lambda build` command to natively compile your Lambda functions in the project.
The resulting artifacts such as binaries or zips, will be placed in the `target/lambda` directory.
This is an example of the output produced by this command:

```
❯ tree target/lambda
target/lambda
├── delete-product
│   └── bootstrap
├── dynamodb-streams
│   └── bootstrap
├── get-product
│   └── bootstrap
├── get-products
│   └── bootstrap
└── put-product
    └── bootstrap

5 directories, 5 files
```

#### Build - Output Format

By default, cargo-lambda produces a binary artifact for each Lambda functions in the project.
However, you can configure cargo-lambda to produce a ready to upload zip artifact.

The `--output-format` parameter controls the output format, the two current options are `zip` and `binary` with `binary` being the default.

Example usage to create a zip.

```
cargo lambda build --output-format zip
```

#### Build - Architectures

By default, cargo-lambda compiles the code for Linux X86-64 architectures, you can compile for Linux ARM architectures by providing the right target:

```
cargo lambda build --target aarch64-unknown-linux-gnu
```

ℹ️ Starting in version 0.6.2, you can use the shortcut `--arm64` to compile your functions for Linux ARM architectures:

```
cargo lambda build --arm64
```

#### Build - Compilation Profiles

By default, cargo-lambda compiles the code in `debug` mode. If you want to change the profile to compile in `release` mode, you can provide the right flag.

```
cargo lambda build --release
```

When you compile your code in release mode, cargo-lambda will strip the binaries from all debug symbols to reduce the binary size.

#### Build - Extensions

cargo-lambda can also build Lambda Extensions written in Rust. If you want to build a extension, use the flag `--extension` to put the output under `target/lambda/extensions`, so you don't mix extensions and functions.

```
cargo lambda build --release --extension
```

If you want to create a zip file with the structure that AWS Lambda expects to find extensions in, add the `--output-format` flag to the previous command, and cargo-lambda will zip the extensions directory with your extension inside.

```
cargo lambda build --release --extension --output-format zip
```

#### Build - How does it work?

cargo-lambda uses [Zig](https://ziglang.org) and [cargo-zigbuild](https://crates.io/crates/cargo-zigbuild)
to compile the code for the right architecture. If Zig is not installed in your host machine, the first time that your run cargo-lambda, it will guide you through some installation options. If you run cargo-lambda in a non-interactive shell, the build process will fail until you install that dependency.

### Watch

⚠️ This subcommand used to be called `start`. Both names still work, as `start` is an alias for `watch`.

The watch subcommand emulates the AWS Lambda control plane API. Run this command at the root of a Rust workspace and cargo-lambda will use cargo-watch to hot compile changes in your Lambda functions. Use flag `--no-reload` to avoid hot compilation.

⚠️ This command works best with the **[Lambda Runtime version 0.5.1](https://crates.io/crates/lambda_runtime/0.5.1)**. Previous versions of the runtime are likely to crash with serialization errors.

```
cargo lambda watch
```

The function is not compiled until the first time that you try to execute it. See the [invoke](#invoke) command to learn how to execute a function. Cargo will run the command `cargo run --bin FUNCTION_NAME` to try to compile the function. `FUNCTION_NAME` can be either the name of the package if the package has only one binary, or the binary name in the `[[bin]]` section if the package includes more than one binary.

#### Watch - Environment variables

If you need to set environment variables for your function to run, you can specify them in the metadata section of your Cargo.toml file.

Use the section `package.metadata.lambda.env` to set global variables that will applied to all functions in your package:

```toml
[package]
name = "basic-lambda"

[package.metadata.lambda.env]
RUST_LOG = "debug"
MY_CUSTOM_ENV_VARIABLE = "custom value"
```

If you have more than one function in the same package, and you want to set specific variables for each one of them, you can use a section named after each one of the binaries in your package, `package.metadata.lambda.bin.BINARY_NAME`:

```toml
[package]
name = "lambda-project"

[package.metadata.lambda.env]
RUST_LOG = "debug"

[package.metadata.lambda.bin.get-product.env]
GET_PRODUCT_ENV_VARIABLE = "custom value"

[package.metadata.lambda.bin.add-product.env]
ADD_PRODUCT_ENV_VARIABLE = "custom value"

[[bin]]
name = "get-product"
path = "src/bin/get-product.rs"

[[bin]]
name = "add-product"
path = "src/bin/add-product.rs"
```

#### Watch - Function URLs

The emulator server includes support for [Lambda function URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html) out of the box. Since we're working locally, these URLs are under the `/lambda-url` path instead of under a subdomain. The function that you're trying to access through a URL must respond to Request events using [lambda_http](https://crates.io/crates/lambda_http/), or raw `ApiGatewayV2httpRequest` events.

You can create functions compatible with this feature by running `cargo lambda new --http FUNCTION_NAME`.

To access a function via its HTTP endpoint, start the watch subcommand `cargo lambda watch`, then send requests to the endpoint `http://localhost:9000/lambda-url/FUNCTION_NAME`. You can add any additional path after the function name, or any query parameters.


### Invoke

The invoke subcomand helps you send requests to the control plane emulator, as well as remote functions.

If your Rust project only includes one function, in the package's main.rs file, you can invoke it by sending the data that you want to process, without extra arguments. For example:

```
$ cargo lambda invoke --data-ascii '{"command": "hi"}'
```

If your project includes more than one function, or the binary has a different name than the package, you must provide the name of the Lambda function that you want to invoke, and the payload that you want to send. If you don't know how to find your function's name, it can be in two places:

- If your Cargo.toml file includes a `[package]` section, and it does **not** include a `[[bin]]` section, the function's name is in the `name` attribute under the `[package]` section.
- If your Cargo.toml file includes one or more `[[bin]]` sections, the function's name is in the `name` attribute under the `[[bin]]` section that you want to compile.

In the following example, `basic-lambda` is the function's name as indicated in the package's `[[bin]]` section:

```
$ cargo lambda invoke basic-lambda --data-ascii '{"command": "hi"}'
```

Cargo-Lambda compiles functions on demand when they receive the first invocation. It's normal that the first invocation takes a long time if your code has not compiled with the host compiler before. After the first compilation, Cargo-Lambda will re-compile your code every time you make a change in it, without having to send any other invocation requests.

#### Invoke - Ascii data

The `--data-ascii` flag allows you to send a payload directly from the command line:

```
cargo lambda invoke basic-lambda --data-ascii '{"command": "hi"}'
```

#### Invoke - File data

The `--data-file` flag allows you to read the payload from a file in your file system:

```
cargo lambda invoke basic-lambda --data-file examples/my-payload.json
```

#### Invoke - Example data

The `--data-example` flag allows you to fetch an example payload from the [aws-lambda-events repository](https://github.com/LegNeato/aws-lambda-events/), and use it as your request payload. For example, if you want to use the [example-apigw-request.json](https://github.com/LegNeato/aws-lambda-events/blob/master/aws_lambda_events/src/generated/fixtures/example-apigw-request.json) payload, you have to pass the name `apigw-request` into this flag:

```
cargo lambda invoke http-lambda --data-example apigw-request
```

After the first download, these examples are cached in your home directory, under `.cargo/lambda/invoke-fixtures`.

#### Invoke - Remote

The `--remote` flag allows you to send requests to a remote function deployed on AWS Lambda. This flag assumes that your AWS account has permission to call the `lambda:invokeFunction` operation. You can specify the region where the function is deployed, as well as any credentials profile that the command should use to authenticate you:

```
cargo lambda invoke --remote --data-example apigw-request http-lambda
```

#### Invoke - Output format

The `--output-format` flag allows you to change the output formatting between plain text and pretty-printed JSON formatting. By default, all function outputs are printed as text.

```
cargo lambda invoke --remote --data-example apigw-request --output-format json http-lambda
```

### Deploy

This subcommand uploads functions to AWS Lambda. You can use the same command to create new functions as well as update existent functions code. This command assumes that your AWS account has permissions to call several lambda operations, like `lambda:getFunction`, `lambda:createFunction`, and `lambda:updateFunctionCode`. This subcommand also requires an IAM role with privileges in AWS Lambda.

When you call this subcommand, the function binary must have been created with the [Build](#build) subcommand ahead of time. The command will fail if it cannot find the binary file.

This command automatically detects the architecture that the binary was compiled for, so you don't have to specify it.

The example below deploys a function that has already been compiled with the default flags:

```
cargo lambda deploy --iam-role FULL_ROLE_ARN http-lambda
```

#### Deploy - Function URLs

This subcommand can enable Lambda function URLs for your lambda. Use the flag `--enable-function-url` when you deploy your function, and when the operation completes, the command will print the function URL in the terminal.

⚠️ This flag always configures the function URL without any kind of authorization. Don't use it if you'd like to keep the URL secure.

The example below shows how to enable the function URL for a function during deployment:

```
cargo lambda deploy --iam-role FULL_ROLE_ARN --enable-function-url http-lambda
```

You can use the flag `--disable-function-url` if you want to disable the function URL.

#### Deploy - Environment variables

You can add environment variables to a function during deployment with the flags `--env-var` and `--env-file`.

The flag `--env-var` allows you to pass several variables in the command like with the format `KEY=VALUE`:

```
cargo lambda deploy --iam-role FULL_ROLE_ARN \
  --env-var FOO=BAR --env-var BAZ=QUX \
  http-lambda
```

The flag `--env-file` will read the variables from a file and add them to the function during the deploy. Each variable in the file must be in a new line with the same `KEY=VALUE` format:

```
cargo lambda deploy --iam-role FULL_ROLE_ARN --env-file .env http-lambda
```

#### Deploy - Extensions

cargo-lambda can deploy Lambda Extensions built in Rust by adding the `--extension` flag to the `deploy` command. This command requires you to build the extension first with the same `--extension` flag in the `build` command:

```
cargo lambda build --release --extension
cargo lambda deploy --extension
```

#### Deploy - Other options

Use the `--help` flag to see other options to configure the function's deployment.

#### Deploy - State management

⚠️ The deploy command doesn't use any kind of state management. If you require state management, you should use tools like [SAM Cli](https://github.com/aws/aws-sam-cli) or the [AWS CDK](https://github.com/aws/aws-cdk).

If you modify a flag and run the deploy command twice for the same function, the change will be updated in the function's configuration in AWS Lambda.

## Rust version

This project works with Rust 1.59 and above.

[//]: # 'badges'
[crate-image]: https://img.shields.io/crates/v/cargo-lambda.svg
[crate-link]: https://crates.io/crates/cargo-lambda
[build-image]: https://github.com/cargo-lambda/cargo-lambda/workflows/Build/badge.svg
[build-link]: https://github.com/cargo-lambda/cargo-lambda/actions?query=workflow%3ACI+branch%3Amain


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cargo-lambda/cargo-lambda",
    "name": "cargo-lambda",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": null,
    "keywords": "cargo,subcommand,aws,lambda",
    "author": null,
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "# cargo-lambda\n\n[![crates.io][crate-image]][crate-link]\n[![Build Status][build-image]][build-link]\n\ncargo-lambda is a [Cargo](https://doc.rust-lang.org/cargo/) subcommand to help you work with AWS Lambda.\n\nThe [new](#new) subcommand creates a basic Rust package from a well defined template to help you start writing AWS Lambda functions in Rust.\n\nThe [build](#build) subcommand compiles AWS Lambda functions natively and produces artifacts which you can then [upload to AWS Lambda](#deploy) or use with other echosystem tools, like [SAM Cli](https://github.com/aws/aws-sam-cli) or the [AWS CDK](https://github.com/aws/aws-cdk).\n\nThe [watch](#watch) subcommand boots a development server that emulates interations with the AWS Lambda control plane. This subcommand also reloads your Rust code as you work on it.\n\nThe [invoke](#invoke) subcommand sends requests to the control plane emulator to test and debug interactions with your Lambda functions. This command can also be used to send requests to remote functions once deployed on AWS Lambda.\n\nThe [deploy](#deploy) subcommand uploads functions to AWS Lambda. You can use the same command to create new functions as well as update existent functions code.\n\n## Installation\n\n### With Homebrew (MacOS and Linux)\n\nYou can use [Homebrew](https://brew.sh/) to install cargo-lambda on MacOS and Linux. Run the following commands on your terminal to add our tap, and install cargo-lambda:\n\n```\nbrew tap cargo-lambda/cargo-lambda\nbrew install cargo-lambda\n```\n\n### With Scoop (Windows)\n\nYou can use [Scoop](https://scoop.sh/) to install cargo-lambda on Windows. Run the following commands to add our bucket, and install cargo-lambda:\n\n```\nscoop bucket add cargo-lambda https://github.com/cargo-lambda/scoop-cargo-lambda\nscoop install cargo-lambda/cargo-lambda\n```\n\n### With PyPI\n\nYou can also use [PyPI](https://pypi.org/) to install cargo-lambda:\n\n```\npip install cargo-lambda\n```\n\n### Building from source\n\nInstall cargo-lambda on your host machine with Cargo itself:\n\n```\ncargo install cargo-lambda\n```\n\n\u26a0\ufe0f cargo-install compiles the binary in your system, which usually takes several minutes.\n\n### Downloading a prebuit binary\n\nGo to the [releases](https://github.com/cargo-lambda/cargo-lambda/releases) page, and download a pre-built binary for your specific platform.\n\n## Usage\n\n### New\n\nThe `new` command creates new Rust packages with a basic scheleton to help you start writing AWS Lambda functions with Rust. This command will create this package in a new sub-directory inside the directory where it's invoked. Run `cargo lambda new PACKAGE-NAME` to generate your new package.\n\nThis command uses templates packed as zip files, or from local directories. The [default template](https://github.com/cargo-lambda/default-template) supports HTTP Lambda functions, as well as functions that receive events defined in the [aws_lambda_events crate](https://crates.io/crates/aws-lambda-events). You can provide your own template using the `--template` flag.\n\nThe files `Cargo.toml`, `README.md`, and `src/main.rs` in the template are parsed with [Liquid](https://crates.io/crates/liquid) to dynamically render different files based on a series of global variables. You can see all the variables in [the source code](https://github.com/cargo-lambda/cargo-lambda/blob/main/crates/cargo-lambda-new/src/lib.rs#L167-L178).\n\nAfter creating a new package, you can use the [build](#build) command described below to compile the source code.\n\n### Build\n\nWithin a Rust project that includes a `Cargo.toml` file, run the `cargo lambda build` command to natively compile your Lambda functions in the project.\nThe resulting artifacts such as binaries or zips, will be placed in the `target/lambda` directory.\nThis is an example of the output produced by this command:\n\n```\n\u276f tree target/lambda\ntarget/lambda\n\u251c\u2500\u2500 delete-product\n\u2502   \u2514\u2500\u2500 bootstrap\n\u251c\u2500\u2500 dynamodb-streams\n\u2502   \u2514\u2500\u2500 bootstrap\n\u251c\u2500\u2500 get-product\n\u2502   \u2514\u2500\u2500 bootstrap\n\u251c\u2500\u2500 get-products\n\u2502   \u2514\u2500\u2500 bootstrap\n\u2514\u2500\u2500 put-product\n    \u2514\u2500\u2500 bootstrap\n\n5 directories, 5 files\n```\n\n#### Build - Output Format\n\nBy default, cargo-lambda produces a binary artifact for each Lambda functions in the project.\nHowever, you can configure cargo-lambda to produce a ready to upload zip artifact.\n\nThe `--output-format` parameter controls the output format, the two current options are `zip` and `binary` with `binary` being the default.\n\nExample usage to create a zip.\n\n```\ncargo lambda build --output-format zip\n```\n\n#### Build - Architectures\n\nBy default, cargo-lambda compiles the code for Linux X86-64 architectures, you can compile for Linux ARM architectures by providing the right target:\n\n```\ncargo lambda build --target aarch64-unknown-linux-gnu\n```\n\n\u2139\ufe0f Starting in version 0.6.2, you can use the shortcut `--arm64` to compile your functions for Linux ARM architectures:\n\n```\ncargo lambda build --arm64\n```\n\n#### Build - Compilation Profiles\n\nBy default, cargo-lambda compiles the code in `debug` mode. If you want to change the profile to compile in `release` mode, you can provide the right flag.\n\n```\ncargo lambda build --release\n```\n\nWhen you compile your code in release mode, cargo-lambda will strip the binaries from all debug symbols to reduce the binary size.\n\n#### Build - Extensions\n\ncargo-lambda can also build Lambda Extensions written in Rust. If you want to build a extension, use the flag `--extension` to put the output under `target/lambda/extensions`, so you don't mix extensions and functions.\n\n```\ncargo lambda build --release --extension\n```\n\nIf you want to create a zip file with the structure that AWS Lambda expects to find extensions in, add the `--output-format` flag to the previous command, and cargo-lambda will zip the extensions directory with your extension inside.\n\n```\ncargo lambda build --release --extension --output-format zip\n```\n\n#### Build - How does it work?\n\ncargo-lambda uses [Zig](https://ziglang.org) and [cargo-zigbuild](https://crates.io/crates/cargo-zigbuild)\nto compile the code for the right architecture. If Zig is not installed in your host machine, the first time that your run cargo-lambda, it will guide you through some installation options. If you run cargo-lambda in a non-interactive shell, the build process will fail until you install that dependency.\n\n### Watch\n\n\u26a0\ufe0f This subcommand used to be called `start`. Both names still work, as `start` is an alias for `watch`.\n\nThe watch subcommand emulates the AWS Lambda control plane API. Run this command at the root of a Rust workspace and cargo-lambda will use cargo-watch to hot compile changes in your Lambda functions. Use flag `--no-reload` to avoid hot compilation.\n\n\u26a0\ufe0f This command works best with the **[Lambda Runtime version 0.5.1](https://crates.io/crates/lambda_runtime/0.5.1)**. Previous versions of the runtime are likely to crash with serialization errors.\n\n```\ncargo lambda watch\n```\n\nThe function is not compiled until the first time that you try to execute it. See the [invoke](#invoke) command to learn how to execute a function. Cargo will run the command `cargo run --bin FUNCTION_NAME` to try to compile the function. `FUNCTION_NAME` can be either the name of the package if the package has only one binary, or the binary name in the `[[bin]]` section if the package includes more than one binary.\n\n#### Watch - Environment variables\n\nIf you need to set environment variables for your function to run, you can specify them in the metadata section of your Cargo.toml file.\n\nUse the section `package.metadata.lambda.env` to set global variables that will applied to all functions in your package:\n\n```toml\n[package]\nname = \"basic-lambda\"\n\n[package.metadata.lambda.env]\nRUST_LOG = \"debug\"\nMY_CUSTOM_ENV_VARIABLE = \"custom value\"\n```\n\nIf you have more than one function in the same package, and you want to set specific variables for each one of them, you can use a section named after each one of the binaries in your package, `package.metadata.lambda.bin.BINARY_NAME`:\n\n```toml\n[package]\nname = \"lambda-project\"\n\n[package.metadata.lambda.env]\nRUST_LOG = \"debug\"\n\n[package.metadata.lambda.bin.get-product.env]\nGET_PRODUCT_ENV_VARIABLE = \"custom value\"\n\n[package.metadata.lambda.bin.add-product.env]\nADD_PRODUCT_ENV_VARIABLE = \"custom value\"\n\n[[bin]]\nname = \"get-product\"\npath = \"src/bin/get-product.rs\"\n\n[[bin]]\nname = \"add-product\"\npath = \"src/bin/add-product.rs\"\n```\n\n#### Watch - Function URLs\n\nThe emulator server includes support for [Lambda function URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html) out of the box. Since we're working locally, these URLs are under the `/lambda-url` path instead of under a subdomain. The function that you're trying to access through a URL must respond to Request events using [lambda_http](https://crates.io/crates/lambda_http/), or raw `ApiGatewayV2httpRequest` events.\n\nYou can create functions compatible with this feature by running `cargo lambda new --http FUNCTION_NAME`.\n\nTo access a function via its HTTP endpoint, start the watch subcommand `cargo lambda watch`, then send requests to the endpoint `http://localhost:9000/lambda-url/FUNCTION_NAME`. You can add any additional path after the function name, or any query parameters.\n\n\n### Invoke\n\nThe invoke subcomand helps you send requests to the control plane emulator, as well as remote functions.\n\nIf your Rust project only includes one function, in the package's main.rs file, you can invoke it by sending the data that you want to process, without extra arguments. For example:\n\n```\n$ cargo lambda invoke --data-ascii '{\"command\": \"hi\"}'\n```\n\nIf your project includes more than one function, or the binary has a different name than the package, you must provide the name of the Lambda function that you want to invoke, and the payload that you want to send. If you don't know how to find your function's name, it can be in two places:\n\n- If your Cargo.toml file includes a `[package]` section, and it does **not** include a `[[bin]]` section, the function's name is in the `name` attribute under the `[package]` section.\n- If your Cargo.toml file includes one or more `[[bin]]` sections, the function's name is in the `name` attribute under the `[[bin]]` section that you want to compile.\n\nIn the following example, `basic-lambda` is the function's name as indicated in the package's `[[bin]]` section:\n\n```\n$ cargo lambda invoke basic-lambda --data-ascii '{\"command\": \"hi\"}'\n```\n\nCargo-Lambda compiles functions on demand when they receive the first invocation. It's normal that the first invocation takes a long time if your code has not compiled with the host compiler before. After the first compilation, Cargo-Lambda will re-compile your code every time you make a change in it, without having to send any other invocation requests.\n\n#### Invoke - Ascii data\n\nThe `--data-ascii` flag allows you to send a payload directly from the command line:\n\n```\ncargo lambda invoke basic-lambda --data-ascii '{\"command\": \"hi\"}'\n```\n\n#### Invoke - File data\n\nThe `--data-file` flag allows you to read the payload from a file in your file system:\n\n```\ncargo lambda invoke basic-lambda --data-file examples/my-payload.json\n```\n\n#### Invoke - Example data\n\nThe `--data-example` flag allows you to fetch an example payload from the [aws-lambda-events repository](https://github.com/LegNeato/aws-lambda-events/), and use it as your request payload. For example, if you want to use the [example-apigw-request.json](https://github.com/LegNeato/aws-lambda-events/blob/master/aws_lambda_events/src/generated/fixtures/example-apigw-request.json) payload, you have to pass the name `apigw-request` into this flag:\n\n```\ncargo lambda invoke http-lambda --data-example apigw-request\n```\n\nAfter the first download, these examples are cached in your home directory, under `.cargo/lambda/invoke-fixtures`.\n\n#### Invoke - Remote\n\nThe `--remote` flag allows you to send requests to a remote function deployed on AWS Lambda. This flag assumes that your AWS account has permission to call the `lambda:invokeFunction` operation. You can specify the region where the function is deployed, as well as any credentials profile that the command should use to authenticate you:\n\n```\ncargo lambda invoke --remote --data-example apigw-request http-lambda\n```\n\n#### Invoke - Output format\n\nThe `--output-format` flag allows you to change the output formatting between plain text and pretty-printed JSON formatting. By default, all function outputs are printed as text.\n\n```\ncargo lambda invoke --remote --data-example apigw-request --output-format json http-lambda\n```\n\n### Deploy\n\nThis subcommand uploads functions to AWS Lambda. You can use the same command to create new functions as well as update existent functions code. This command assumes that your AWS account has permissions to call several lambda operations, like `lambda:getFunction`, `lambda:createFunction`, and `lambda:updateFunctionCode`. This subcommand also requires an IAM role with privileges in AWS Lambda.\n\nWhen you call this subcommand, the function binary must have been created with the [Build](#build) subcommand ahead of time. The command will fail if it cannot find the binary file.\n\nThis command automatically detects the architecture that the binary was compiled for, so you don't have to specify it.\n\nThe example below deploys a function that has already been compiled with the default flags:\n\n```\ncargo lambda deploy --iam-role FULL_ROLE_ARN http-lambda\n```\n\n#### Deploy - Function URLs\n\nThis subcommand can enable Lambda function URLs for your lambda. Use the flag `--enable-function-url` when you deploy your function, and when the operation completes, the command will print the function URL in the terminal.\n\n\u26a0\ufe0f This flag always configures the function URL without any kind of authorization. Don't use it if you'd like to keep the URL secure.\n\nThe example below shows how to enable the function URL for a function during deployment:\n\n```\ncargo lambda deploy --iam-role FULL_ROLE_ARN --enable-function-url http-lambda\n```\n\nYou can use the flag `--disable-function-url` if you want to disable the function URL.\n\n#### Deploy - Environment variables\n\nYou can add environment variables to a function during deployment with the flags `--env-var` and `--env-file`.\n\nThe flag `--env-var` allows you to pass several variables in the command like with the format `KEY=VALUE`:\n\n```\ncargo lambda deploy --iam-role FULL_ROLE_ARN \\\n  --env-var FOO=BAR --env-var BAZ=QUX \\\n  http-lambda\n```\n\nThe flag `--env-file` will read the variables from a file and add them to the function during the deploy. Each variable in the file must be in a new line with the same `KEY=VALUE` format:\n\n```\ncargo lambda deploy --iam-role FULL_ROLE_ARN --env-file .env http-lambda\n```\n\n#### Deploy - Extensions\n\ncargo-lambda can deploy Lambda Extensions built in Rust by adding the `--extension` flag to the `deploy` command. This command requires you to build the extension first with the same `--extension` flag in the `build` command:\n\n```\ncargo lambda build --release --extension\ncargo lambda deploy --extension\n```\n\n#### Deploy - Other options\n\nUse the `--help` flag to see other options to configure the function's deployment.\n\n#### Deploy - State management\n\n\u26a0\ufe0f The deploy command doesn't use any kind of state management. If you require state management, you should use tools like [SAM Cli](https://github.com/aws/aws-sam-cli) or the [AWS CDK](https://github.com/aws/aws-cdk).\n\nIf you modify a flag and run the deploy command twice for the same function, the change will be updated in the function's configuration in AWS Lambda.\n\n## Rust version\n\nThis project works with Rust 1.59 and above.\n\n[//]: # 'badges'\n[crate-image]: https://img.shields.io/crates/v/cargo-lambda.svg\n[crate-link]: https://crates.io/crates/cargo-lambda\n[build-image]: https://github.com/cargo-lambda/cargo-lambda/workflows/Build/badge.svg\n[build-link]: https://github.com/cargo-lambda/cargo-lambda/actions?query=workflow%3ACI+branch%3Amain\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Cargo subcommand to work with AWS Lambda",
    "version": "0.8.3",
    "split_keywords": [
        "cargo",
        "subcommand",
        "aws",
        "lambda"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "md5": "97895e4418a17682a04c27b86921348b",
                "sha256": "57fbf0e823b691ea92032cc82d54340400aa30b4d97b0c1006d3929f93de70dd"
            },
            "downloads": -1,
            "filename": "cargo_lambda-0.8.3-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl",
            "has_sig": false,
            "md5_digest": "97895e4418a17682a04c27b86921348b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14686575,
            "upload_time": "2022-06-14T02:08:07",
            "upload_time_iso_8601": "2022-06-14T02:08:07.048269Z",
            "url": "https://files.pythonhosted.org/packages/69/c2/8b859c06d87c869a26acdda4ed55bea329dde3ea622f606c0bd74e20b0fd/cargo_lambda-0.8.3-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "md5": "d40e59b65bee08cc575386203ff39067",
                "sha256": "2c84ffbbaf1ec9ddf2acdde15653c5045ac1b12395a83c2d07fbef81564fa4c7"
            },
            "downloads": -1,
            "filename": "cargo_lambda-0.8.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "d40e59b65bee08cc575386203ff39067",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7567944,
            "upload_time": "2022-06-14T02:08:09",
            "upload_time_iso_8601": "2022-06-14T02:08:09.653421Z",
            "url": "https://files.pythonhosted.org/packages/31/79/e75463838e66b15a9bb7d3e8e2cc80427f80f4af3ce2b2f33c11b2f691cb/cargo_lambda-0.8.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "md5": "545a55c132a771a3ece685f1a91ea223",
                "sha256": "6c80fe0d9b7d04dcc4e4093fba84bc326ead4e8a86f1e9580c148ae77841ea65"
            },
            "downloads": -1,
            "filename": "cargo_lambda-0.8.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
            "has_sig": false,
            "md5_digest": "545a55c132a771a3ece685f1a91ea223",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7479700,
            "upload_time": "2022-06-14T02:08:11",
            "upload_time_iso_8601": "2022-06-14T02:08:11.847516Z",
            "url": "https://files.pythonhosted.org/packages/58/74/0549d9bffe4a3c72179a3e88ebec6daf6a6a258587f66cde8f9bb5e24908/cargo_lambda-0.8.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "md5": "50e7061545ee306fb180efc11005518f",
                "sha256": "57f3d1f6b0962b6b61c1dc2dcfb8fa6b14e43c438c95dea6cc26a3137926b6b4"
            },
            "downloads": -1,
            "filename": "cargo_lambda-0.8.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl",
            "has_sig": false,
            "md5_digest": "50e7061545ee306fb180efc11005518f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8484075,
            "upload_time": "2022-06-14T02:08:14",
            "upload_time_iso_8601": "2022-06-14T02:08:14.352544Z",
            "url": "https://files.pythonhosted.org/packages/ea/53/2f9bbd7660a4b939ede5fa79543090798ee907c65b288ccbec77628c792b/cargo_lambda-0.8.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "md5": "a857745c415e82d527d7c5d003915a85",
                "sha256": "f11aad50bf7da9a4f511353c6a0d4d521679bfa12547f9d45ba70b3e0c557451"
            },
            "downloads": -1,
            "filename": "cargo_lambda-0.8.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "a857745c415e82d527d7c5d003915a85",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8495015,
            "upload_time": "2022-06-14T02:08:17",
            "upload_time_iso_8601": "2022-06-14T02:08:17.005717Z",
            "url": "https://files.pythonhosted.org/packages/19/03/d4f91ba2b27e60419888b4f198179c3fa8ba7e403c0852f7d1dcbaf74673/cargo_lambda-0.8.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "md5": "e91fc1a7eac22eddc65104cd4e37a4ed",
                "sha256": "512d515c45bd1d7e04a676e43c82965f2dd960ff399db048ec2aa26620357219"
            },
            "downloads": -1,
            "filename": "cargo_lambda-0.8.3-py3-none-win32.whl",
            "has_sig": false,
            "md5_digest": "e91fc1a7eac22eddc65104cd4e37a4ed",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6886058,
            "upload_time": "2022-06-14T02:08:19",
            "upload_time_iso_8601": "2022-06-14T02:08:19.591626Z",
            "url": "https://files.pythonhosted.org/packages/26/e3/cec53630fb39aaf91f876ab86c2c17373c702b86a085fb594625a7f7920e/cargo_lambda-0.8.3-py3-none-win32.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "md5": "00341916763fc5aea931817aa621492f",
                "sha256": "fe077bc82aa98d9374b29c91a599b0024f812a09543836726a01abaa16888a8c"
            },
            "downloads": -1,
            "filename": "cargo_lambda-0.8.3-py3-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "00341916763fc5aea931817aa621492f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7459758,
            "upload_time": "2022-06-14T02:08:22",
            "upload_time_iso_8601": "2022-06-14T02:08:22.050332Z",
            "url": "https://files.pythonhosted.org/packages/de/6f/de700106a963b244008299c32f6339d4991a5148c8cd16cec9db723a50f5/cargo_lambda-0.8.3-py3-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-06-14 02:08:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "cargo-lambda",
    "github_project": "cargo-lambda",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cargo-lambda"
}
        
Elapsed time: 0.48793s