> ## Documentation Index
> Fetch the complete documentation index at: https://opensre.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS Lambda

> Connect AWS Lambda so OpenSRE can inspect function configuration, invocation logs, and runtime errors during investigations.

OpenSRE integrates with AWS Lambda to inspect function configuration, retrieve recent invocation logs from CloudWatch, and investigate runtime failures during incident response.

## Prerequisites

* An AWS account with AWS Lambda functions
* AWS credentials configured for the runtime
* Permission to access Lambda and CloudWatch Logs

## Setup

### Option 1: Interactive CLI

```bash theme={null}
opensre integrations setup
```

Select **AWS Lambda** when prompted.

### Option 2: Environment variables

Add the following to your `.env`:

```bash theme={null}
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_REGION=us-east-1
AWS_SESSION_TOKEN=your-session-token    # optional
```

| Variable                | Required | Description                                    |
| ----------------------- | -------- | ---------------------------------------------- |
| `AWS_ACCESS_KEY_ID`     | Yes      | AWS access key ID                              |
| `AWS_SECRET_ACCESS_KEY` | Yes      | AWS secret access key                          |
| `AWS_REGION`            | No       | AWS region (defaults to `us-east-1`)           |
| `AWS_SESSION_TOKEN`     | No       | Session token when using temporary credentials |

## Verify

```bash theme={null}
opensre integrations verify aws_lambda
```

Expected output:

```text theme={null}
Service: aws_lambda
Status: passed
Detail: Successfully connected to AWS Lambda
```

## Investigation tools

When investigating AWS Lambda alerts, OpenSRE provides:

* **Lambda Configuration** — inspect runtime, handler, timeout, memory, IAM role, environment variables, and deployed version.
* **Lambda Inspect** — retrieve deployment package metadata and inspect function contents when available.
* **Lambda Invocation Logs** — retrieve recent invocation logs from CloudWatch Logs.
* **Lambda Errors** — investigate recent runtime failures and execution errors.

All operations are read-only.

## Gotcha

Lambda invocation history is retrieved from **CloudWatch Logs**. Ensure the configured AWS credentials have permission to access both **AWS Lambda** and **CloudWatch Logs**, otherwise log retrieval may fail even if Lambda access succeeds.
