> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# circleci/aws-serverless

"Build, Test, and Deploy your AWS serverless applications on CircleCI utilizing the AWS Serverless Application Model. Learn More: https://aws.amazon.com/serverless/sam/ Repo: https://github.com/CircleCI-Public/aws-serverless-orb"


## Commands

### build

Build your Lambda source code and generate deployment artifacts that target Lambda's execution environment. The sam build command iterates through the functions in your application, looks for a manifest file (such as requirements.txt) that contains the dependencies, and automatically creates deployment artifacts that you can deploy to Lambda using the sam package and sam deploy commands. You can also use sam build in combination with other commands like sam local invoke to test your application locally.
Optionally package for s3 or run locally.
Ensure CLI has been installed before utilizing.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `aws-region` | env_var_name | AWS_DEFAULT_REGION | Sets the AWS Region of the service (for example, us-east-1). |
| `base-dir` | string |  | Resolves relative paths to the function's source code with respect to this folder. Use this if the AWS SAM template and your source code aren't in the same enclosing folder. By default, relative paths are resolved with respect to the template's location. |
| `build-dir` | string |  | The path to a folder where the built artifacts are stored. |
| `debug` | boolean | false | Turns on debug logging. |
| `output-template-file` | string |  | The path to the file where the command writes the packaged template. If you don't specify a path, the command writes the template to the standard output. |
| `profile-name` | string | default | Select a specific profile from your credential file to get AWS credentials. |
| `s3-bucket` | string |  | The name of the S3 bucket where this command uploads the artifacts that are referenced in your template. If this option is set, the SAM package command will be run automatically. |
| `template` | string |  | The AWS SAM template file |
| `use-container` | boolean | true | If your functions depend on packages that have natively compiled dependencies, use this flag to build your function inside an AWS Lambda-like Docker container. |
| `validate` | boolean | true | Validate your template file. This will run unless manually set to false. |

### deploy

Deploys an AWS SAM application. It is recommended to create a Workflow to build and deploy your SAM app to a development stack for testing before deploying to a production stack.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `aws-region` | env_var_name | AWS_DEFAULT_REGION | Env var of AWS region to operate in
(defaults to AWS_DEFAULT_REGION)
 |
| `capabilities` | string | CAPABILITY_IAM | A list of capabilities that you must specify before AWS Cloudformation can create certain stacks. The only valid values are CAPABILITY_IAM and CAPABILITY_NAMED_IAM. If you have IAM resources, you can specify either capability. If you have IAM resources with custom names, you must specify CAPABILITY_NAMED_IAM. |
| `debug` | boolean | false | Turns on debug logging. |
| `profile-name` | string | default | Select a specific profile from your credential file to get AWS credentials. |
| `stack-name` | string |  | The name of the AWS CloudFormation stack you're deploying to. If you specify an existing stack, the command updates the stack. If you specify a new stack, the command creates it. |
| `template` | string |  | The path where your AWS SAM template file is located. |

### install

Install and configure the AWS CLI and the SAM CLI in one command. Must have IAM credentials set via environment variables.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `aws-access-key-id` | env_var_name | AWS_ACCESS_KEY_ID | AWS access key id for IAM role. Set this to the name of
the environment variable you will use to hold this
value, i.e. AWS_ACCESS_KEY.
 |
| `aws-region` | env_var_name | AWS_DEFAULT_REGION | Env var of AWS region to operate in
(defaults to AWS_DEFAULT_REGION)
 |
| `aws-secret-access-key` | env_var_name | AWS_SECRET_ACCESS_KEY | AWS secret key for IAM role. Set this to the name of
the environment variable you will use to hold this
value, i.e. $AWS_SECRET_ACCESS_KEY.
 |
| `configure-default-region` | boolean | true | Some AWS actions don't require a region; set this to false if you do not want to store a default region in ~/.aws/config
 |
| `profile-name` | string | default | Profile name to be configured. |
| `python_version` | string |  | If set, this version of Python will be installed and set with pyenv globally. ex: "3.7.0" This is only for the local environment and will not have any effect if use-container is enabled. |

### local-start-api

Run your SAM app locally in the background and wait until the server is online. This is an alias to the SAM CLI.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `debug` | boolean | false | Enable debug logging
 |
| `dockerize_version` | string | 0.6.1 | Dockerize is a utility that will continuously attempt to connect to an endpoint. Used to wait for the API to come online. |
| `endpoint` | string |  | After invoking the local-api this endpoint will be tested against until it is online before allowing the job to continue. |
| `env-vars` | string |  | The JSON file that contains values for the Lambda function's environment variables. |
| `port` | integer | 3000 | The local port number to listen on |
| `template` | string |  | The path where your AWS SAM template file is located. |
| `timeout` | integer | 5 | The number in minutes to wait for the API to come online. |

## Jobs

### deploy

Deploy serverless applications.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `aws-region` | env_var_name | AWS_DEFAULT_REGION | Sets the AWS Region of the service (for example, us-east-1). |
| `base-dir` | string |  | Resolves relative paths to the function's source code with respect to this folder. Use this if the AWS SAM template and your source code aren't in the same enclosing folder. By default, relative paths are resolved with respect to the template's location. |
| `build-dir` | string |  | The path to a folder where the built artifacts are stored. |
| `capabilities` | string | CAPABILITY_IAM |  |
| `debug` | boolean | false | Turns on debug logging. |
| `pre-deploy` | steps |  | Run these steps prior to deploying the application, but after the checkout, install, build, and package steps. |
| `profile-name` | string | default | Select a specific profile from your credential file to get AWS credentials. |
| `python_version` | string |  | If set, this version of Python will be installed and set with pyenv globally. ex: "3.7.0" This is only for the local environment and will not have any effect if use-container is enabled.9 |
| `s3-bucket` | string |  | The name of the S3 bucket where this command uploads the artifacts that are referenced in your template. If this option is set, the SAM package command will be run automatically. |
| `stack-name` | string |  | The name of the AWS CloudFormation stack you're deploying to. If you specify an existing stack, the command updates the stack. If you specify a new stack, the command creates it. |
| `template` | string |  | The AWS SAM template file |
| `use-container` | boolean | true | If your functions depend on packages that have natively compiled dependencies, use this flag to build your function inside an AWS Lambda-like Docker container. |
| `validate` | boolean | true | Validate your template file. This will run unless manually set to false. |

## Executors

### default

Machine executor provided by CircleCI. Needed for privileged access to Docker for the SAM CLI.


## Examples

### build_test_deploy

Test application in a staging environment in Cloudformation before deploying to production.


```yaml
jobs:
  test_my_api:
    executor: aws-servlerless/default
    steps:
      - run: echo "Run your tests here"
orbs:
  aws-serverless: circleci/aws-serverless@x.y.z
version: 2.1
workflows:
  test_and_deploy:
    jobs:
      - aws-serverless/deploy:
          name: deploy-staging
          stack-name: staging-stack
          template: ./path/to/template.yml
      - test_my_api:
          requires:
            - deploy-staging
      - aws-serverless/deploy:
          name: deploy-production
          requires:
            - test_my_api
          stack-name: production-stack
          template: ./path/to/template.yml
```

### install-cli

Install the SAM CLI to interact with the CLI directly.


```yaml
jobs:
  build_app:
    executor: aws-serverless/default
    steps:
      - checkout
      - aws-serverless/install
      - run: sam build
orbs:
  aws-serverless: circleci/aws-serverless@x.y.z
version: 2.1
workflows:
  my-workflow:
    jobs:
      - build_app
```

### local_test

Install the SAM CLI to interact with the CLI directly.


```yaml
jobs:
  build_and_package:
    executor: aws-serverless/default
    steps:
      - checkout
      - aws-serverless/install
      - aws-serverless/local-start-api
orbs:
  aws-serverless: circleci/aws-serverless@x.y.z
version: 2.1
```