> 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/overview-2/serverless-package.md).

# Step Library

Bundle Lambda functions and prepare the CloudFormation deployment package using the Serverless Framework package command.

The Serverless Package step bundles your Lambda functions and prepares the CloudFormation template for upload to S3. It runs before the Serverless Deploy step and is added automatically when you select the **Serverless Deployment With Rollback Strategy**.

***

### What you will learn <a href="#what-you-will-learn" id="what-you-will-learn"></a>

* The parameters available on the Serverless Package step.
* How the Package step downloads the artifact and runs `serverless package`.

***

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

Ensure the following are in place before adding this step to your stage:

* A configured [Serverless service](/continuous-delivery/3.0/use-deployments/overview-2/serverless-services.md) with a manifest and artifact source.
* A configured [Serverless infrastructure](/continuous-delivery/3.0/use-deployments/overview-2/serverless-infrastructure.md) with an AWS connector, region, and stage.
* The stage runtime environment configured with a Kubernetes cluster connector. Go to [Serverless deployment](/continuous-delivery/3.0/use-deployments/overview-2/serverless-deployment.md) for setup details.

***

### Configure the step <a href="#configure-the-step" id="configure-the-step"></a>

The following parameters are available on the Serverless Package step.

| Parameter                 | Required | Description                                                                                                                             |
| ------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| **Name**                  | Yes      | Display name for this step in the stage canvas. Default: `Serverless Aws Lambda Package V2`.                                            |
| **Container Registry**    | Yes      | A Harness Docker Registry connector pointing to the registry that hosts the step image.                                                 |
| **Image**                 | Yes      | The `harness/serverless-plugin` image and tag to use, for example `harness/serverless-plugin:nodejs20.x-3.39.0-1.1.0-beta-linux-amd64`. |
| **Command Options**       | No       | Additional flags passed to `serverless package`, for example `--verbose`. Appended after `--stage` and `--region`.                      |
| **Pre-Execute Command**   | No       | Shell command that runs before the step logic. Use this to install dependencies or change directory.                                    |
| **Environment Variables** | No       | Key-value pairs injected into the container.                                                                                            |

***

### How the step works <a href="#how-it-works" id="how-it-works"></a>

By the time the Package step runs, the platform has already fetched and rendered the manifest. Harness Manifest Rendering copies the manifest files into the container at `/harness/<manifest-id>/<folder-path>/`, and Harness Manifest Templating resolves all Go template expressions (including the artifact path) in place.

The Package step runs two sub-steps:

1. **Download Artifact Action:** Downloads the primary artifact (ZIP file or Docker image) from the configured artifact source to `/harness/artifacts/primary/<filename>`. The download path is also available as the `ARTIFACT_DOWNLOAD_PATH` environment variable for use in subsequent steps.
2. **Serverless Package Action:** Runs `serverless package --stage <stage> --region <region>` in the manifest directory. The manifest at this point already contains the resolved artifact path, for example:

```yaml
package:
  artifact: /harness/artifacts/primary/handler1.zip
```

After packaging completes, the `.serverless/` directory contains the packaged artifacts and CloudFormation template, ready for the Deploy step.

***

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

* Go to [Serverless Deploy](/continuous-delivery/3.0/use-deployments/overview-2/serverless-package/serverless-deploy.md) to review the deployment step

{% @harness-feedback/feedback %}
