> ## Documentation Index
> Fetch the complete documentation index at: https://kosli-docs-agentcore-how-to-355.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# kosli snapshot lambda

> Report a snapshot of artifacts deployed as one or more AWS Lambda functions and their digests to Kosli.

## Synopsis

```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
kosli snapshot lambda ENVIRONMENT-NAME [flags]
```

Report a snapshot of artifacts deployed as one or more AWS Lambda functions and their digests to Kosli.\
Skip `--function-names` and `--function-names-regex` to report all functions in a given AWS account. Or use `--exclude` and/or `--exclude-regex` to report all functions excluding some.

To authenticate to AWS, you can either:

1. provide the AWS static credentials via flags or by exporting the equivalent KOSLI env vars (e.g. KOSLI\_AWS\_KEY\_ID)
2. export the AWS env vars (e.g. AWS\_ACCESS\_KEY\_ID).
3. Use a shared config/credentials file under the \$HOME/.aws

Option 1 takes highest precedence, while option 3 is the lowest.
More details can be found here: [https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-credentials](https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-credentials)

## Flags

| Flag                     | Type    | Description                                                                                                                                                                                                                                           |
| :----------------------- | :------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--aws-key-id`           | string  | The AWS access key ID.                                                                                                                                                                                                                                |
| `--aws-region`           | string  | The AWS region.                                                                                                                                                                                                                                       |
| `--aws-secret-key`       | string  | The AWS secret access key.                                                                                                                                                                                                                            |
| `-D`, `--dry-run`        | bool    | \[optional] Run in dry-run mode. When enabled, no data is sent to Kosli and the CLI exits with 0 exit code regardless of any errors.                                                                                                                  |
| `--exclude`              | strings | \[optional] The comma-separated list of AWS Lambda function names to be excluded. Cannot be used together with `--function-names`                                                                                                                     |
| `--exclude-regex`        | strings | \[optional] The comma-separated list of name regex patterns for AWS Lambda functions to be excluded. Cannot be used together with `--function-names`. Allowed regex patterns are described in [RE2 syntax](https://github.com/google/re2/wiki/Syntax) |
| `--function-name`        | strings | \[optional] The name of the AWS Lambda function. (DEPRECATED: use `--function-names` instead)                                                                                                                                                         |
| `--function-names`       | strings | \[optional] The comma-separated list of AWS Lambda function names to be reported. Cannot be used together with `--exclude` or `--exclude-regex`.                                                                                                      |
| `--function-names-regex` | strings | \[optional] The comma-separated list of AWS Lambda function names regex patterns to be reported. Cannot be used together with `--exclude` or `--exclude-regex`.                                                                                       |
| `--function-version`     | string  | \[optional] The version of the AWS Lambda function. (DEPRECATED: `--function-version` is no longer supported. It will be removed in a future release.)                                                                                                |
| `-h`, `--help`           | bool    | help for lambda                                                                                                                                                                                                                                       |

## Flags inherited from parent commands

| Flag                        | Type   | Description                                                                                                                                                                                                                                              |
| :-------------------------- | :----- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-a`, `--api-token`         | string | The Kosli API token.                                                                                                                                                                                                                                     |
| `-A`, `--auto-environment`  | bool   | \[optional] Create the environment (with the type inferred from the snapshot subcommand) if it does not already exist, before reporting the snapshot.                                                                                                    |
| `-c`, `--config-file`       | string | \[optional] The Kosli config file path. (default "kosli")                                                                                                                                                                                                |
| `--debug`                   | bool   | \[optional] Print debug logs to stdout.                                                                                                                                                                                                                  |
| `--environment-description` | string | \[optional] The environment description.                                                                                                                                                                                                                 |
| `--exclude-scaling`         | bool   | \[optional] Exclude scaling events for snapshots. Snapshots with scaling changes will not result in new environment records. (DEPRECATED: this flag is deprecated and will be removed in a future version. Scaling events do not trigger new snapshots.) |
| `-H`, `--host`              | string | \[defaulted] The Kosli endpoint. (default "[https://app.kosli.com](https://app.kosli.com)")                                                                                                                                                              |
| `--http-proxy`              | string | \[optional] The HTTP proxy URL including protocol and port number. e.g. `http://proxy-server-ip:proxy-port`                                                                                                                                              |
| `--include-scaling`         | bool   | \[optional] Include scaling events for snapshots. Snapshots with scaling changes will result in new environment records. (DEPRECATED: this flag is deprecated and will be removed in a future version. Scaling events do not trigger new snapshots.)     |
| `-r`, `--max-api-retries`   | int    | \[defaulted] How many times should API calls be retried when the API host is not reachable. (default 3)                                                                                                                                                  |
| `--org`                     | string | The Kosli organization.                                                                                                                                                                                                                                  |
| `-q`, `--quiet`             | bool   | \[optional] Suppress non-critical warning messages. Errors and normal output are not affected. If both `--quiet` and `--debug` are set, `--debug` wins.                                                                                                  |

## Examples Use Cases

These examples all assume that the flags  `--api-token`, `--org`, `--host`, (and `--flow`, `--trail` when required), are [set/provided](/getting_started/install/#assigning-flags-via-environment-variables).

<AccordionGroup>
  <Accordion title="report all Lambda functions running in an AWS account (AWS auth provided in env variables)">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    export AWS_REGION=yourAWSRegion
    export AWS_ACCESS_KEY_ID=yourAWSAccessKeyID
    export AWS_SECRET_ACCESS_KEY=yourAWSSecretAccessKey

    kosli snapshot lambda yourEnvironmentName 

    ```
  </Accordion>

  <Accordion title="report all (excluding some) Lambda functions running in an AWS account (AWS auth provided in env variables)">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    export AWS_REGION=yourAWSRegion
    export AWS_ACCESS_KEY_ID=yourAWSAccessKeyID
    export AWS_SECRET_ACCESS_KEY=yourAWSSecretAccessKey

    kosli snapshot lambda yourEnvironmentName 
        --exclude function1,function2 
    	--exclude-regex "^not-wanted.*" 

    ```
  </Accordion>

  <Accordion title="report what is running in the latest version of an AWS Lambda function (AWS auth provided in env variables)">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    export AWS_REGION=yourAWSRegion
    export AWS_ACCESS_KEY_ID=yourAWSAccessKeyID
    export AWS_SECRET_ACCESS_KEY=yourAWSSecretAccessKey

    kosli snapshot lambda yourEnvironmentName 
    	--function-names yourFunctionName 

    ```
  </Accordion>

  <Accordion title="report what is running in the latest version of AWS Lambda functions that match a name regex">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    export AWS_REGION=yourAWSRegion
    export AWS_ACCESS_KEY_ID=yourAWSAccessKeyID
    export AWS_SECRET_ACCESS_KEY=yourAWSSecretAccessKey

    kosli snapshot lambda yourEnvironmentName 
    	--function-names-regex yourFunctionNameRegexPattern 

    ```
  </Accordion>

  <Accordion title="report what is running in the latest version of multiple AWS Lambda functions (AWS auth provided in env variables)">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    export AWS_REGION=yourAWSRegion
    export AWS_ACCESS_KEY_ID=yourAWSAccessKeyID
    export AWS_SECRET_ACCESS_KEY=yourAWSSecretAccessKey

    kosli snapshot lambda yourEnvironmentName 
    	--function-names yourFirstFunctionName,yourSecondFunctionName 

    ```
  </Accordion>

  <Accordion title="report what is running in the latest version of an AWS Lambda function (AWS auth provided in flags)">
    ```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
    kosli snapshot lambda yourEnvironmentName 
    	--function-names yourFunctionName 
    	--aws-key-id yourAWSAccessKeyID 
    	--aws-secret-key yourAWSSecretAccessKey 
    	--aws-region yourAWSRegion 
    ```
  </Accordion>
</AccordionGroup>
