> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/3.0/use-deployments/aws-lambda/overview.md).

# Overview

Deploy AWS Lambda functions using Harness CD.

An AWS Lambda stage deploys your Lambda function code and configuration to AWS. You define the service (function definition and artifact), the target infrastructure (AWS account and region), and the deployment strategy. Harness manages the rollout and rolls back automatically on failure.

***

## AWS IAM permissions <a href="#aws-iam-permissions" id="aws-iam-permissions"></a>

The IAM role attached to your AWS connector needs the following managed policies:

| Policy                               | Purpose                                         |
| ------------------------------------ | ----------------------------------------------- |
| `IAMReadOnlyAccess`                  | Verify required policies                        |
| `AWSLambdaRole`                      | Invoke the function                             |
| `AWSLambda_FullAccess`               | Create and update Lambda functions              |
| `AmazonS3ReadOnlyAccess`             | Pull the function ZIP from S3                   |
| `AmazonEC2ContainerRegistryReadOnly` | Pull a container image from ECR (if applicable) |

You also need an **AWS Lambda Execution Role** configured in your AWS account. Go to [AWS Lambda execution role](https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html) in the AWS documentation to set one up.

***

## Set up a Lambda deployment <a href="#set-up-a-lambda-deployment" id="set-up-a-lambda-deployment"></a>

1. Go to **Pipelines** and click **Create Pipeline**.
2. Enter a pipeline name. Under **Storage**, select **Inline** or a Git repository. Click **Create**.
3. A default **Stage 1** is added. You can edit it directly, but the deployment strategy selection step will be skipped. To choose a strategy, delete **Stage 1** and click **+** to add a new stage.
4. Select **Deploy** and click **Set Up Stage**.
5. Enter a stage name and set **Deployment Target** to **AWS Lambda**. Click **Next**.

The wizard walks you through configuring the service, environment, and execution strategy in sequence.

***

## Service <a href="#service" id="service"></a>

A **service** represents what you deploy. For Lambda, it holds the function definition (function name, handler, runtime, memory, and timeout), an optional alias definition for canary routing, the artifact source (S3 ZIP or ECR image), config files, and service-level variables.

Services are independent of pipelines; configure one once and reuse it across stages and pipelines.

Go to [Lambda services](/continuous-delivery/3.0/use-deployments/aws-lambda/lambda-services.md) to configure function definitions, artifact sources, and alias definitions.

***

## Environment and infrastructure <a href="#environment-and-infrastructure" id="environment-and-infrastructure"></a>

An **environment** is a logical deployment target such as development, staging, or production. An **infrastructure definition** within an environment points to the AWS account and region where Harness deploys the function.

The infrastructure definition references an **AWS connector**, which authenticates to AWS using an IAM role. The connector uses a **delegate** running in your network to reach the AWS APIs; no inbound access to your environment is required.

Go to [Lambda infrastructure](/continuous-delivery/3.0/use-deployments/aws-lambda/lambda-infrastructure.md) to configure environments, infrastructure definitions, and connectors.

***

## Deployment strategies <a href="#deployment-strategies" id="deployment-strategies"></a>

Harness supports the following Lambda strategies. Select one when you add a stage.

| Strategy    | What it does                                                                                                                                                                                                                                                           |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Rolling** | Deploys the new function version directly, then shifts 100% of traffic to it immediately.                                                                                                                                                                              |
| **Canary**  | Deploys the new version, shifts a configurable percentage of traffic via an alias, then shifts the remainder once validated. Requires an `AwsLambdaFunctionAliasDefinition` manifest for ZIP artifacts (S3, Artifactory, Nexus); managed automatically for ECR images. |

***

## Stage settings <a href="#stage-settings" id="stage-settings"></a>

Each stage has settings accessible from the stage editor, organized into five sections: **Deploy**, **Code & build**, **Inputs & outputs**, **Execution controls**, and **Runtime Environment**.

### Inputs & outputs <a href="#inputs-and-outputs" id="inputs-and-outputs"></a>

The **Inputs & outputs** section defines the stage's inputs, environment variables, and outputs. Use this section to declare values the stage accepts as runtime inputs, environment variables available to step containers during execution, and outputs the stage exposes to downstream stages.

### Execution controls <a href="#execution-controls" id="execution-controls"></a>

The **Execution controls** section sets conditions, looping strategy, concurrency, failure strategy, and timeout for the stage.

**On failure** defines what Harness does when the stage fails. For Lambda deployments, `stage-rollback` triggers the rollback step and restores the previous function version.

```yaml
on-failure:
  errors: all
  action: stage-rollback
```

**Strategy** configures a looping strategy so the stage runs multiple times across a matrix of values, for example to deploy the same function to multiple regions.

```yaml
strategy:
  matrix:
    region: [us-east-1, eu-west-1]
  max-concurrency: 2
```

### Runtime environment <a href="#runtime-environment" id="runtime-environment"></a>

The **Runtime Environment** section configures where the stage's steps execute. Harness supports three runtime options:

| Runtime           | Description                                                                                                                                         |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Harness Cloud** | Steps run on Harness-hosted infrastructure. No delegate or cluster setup required.                                                                  |
| **Delegate**      | Steps run on any available installed delegate. Harness selects one automatically, or you can inherit from a delegate installed in your environment. |
| **Kubernetes**    | Steps run as containers on a Kubernetes cluster you specify. Requires a Kubernetes connector and a namespace on the delegate's cluster.             |

Example — Kubernetes runtime:

```yaml
runtime:
  kubernetes:
    namespace: <your-delegate-namespace>
    connector: <your-k8s-connector>
    automount-service-token: true
    pull: always
```

***

## Next steps <a href="#next-steps" id="next-steps"></a>

* Go to [Lambda services](/continuous-delivery/3.0/use-deployments/aws-lambda/lambda-services.md) to configure function definitions, artifact sources, and alias definitions.
* Go to [Lambda infrastructure](/continuous-delivery/3.0/use-deployments/aws-lambda/lambda-infrastructure.md) to configure environments and infrastructure definitions.
* Go to [Lambda canary deployment](/continuous-delivery/3.0/use-deployments/aws-lambda/lambda-deployment-strategies/canary.md) to configure the canary strategy.
* Go to [Lambda rolling deployment](/continuous-delivery/3.0/use-deployments/aws-lambda/lambda-deployment-strategies/rolling.md) to configure the rolling strategy.

{% @harness-feedback/feedback %}
