

# Amazon SAM CLI Terraform support
<a name="terraform-support"></a>

This section covers using the Amazon Serverless Application Model Command Line Interface (Amazon SAM CLI) with your Terraform projects and Terraform Cloud.

To provide feedback and submit feature requests, create a [GitHub Issue](https://github.com/aws/aws-sam-cli/issues/new?labels=area%2Fterraform).

**Topics**
+ [Getting started with Terraform support for Amazon SAM CLI](gs-terraform-support.md)
+ [Using the Amazon SAM CLI with Terraform for local debugging and testing](using-samcli-terraform.md)
+ [Using the Amazon SAM CLI with Serverless.tf for local debugging and testing](using-samcli-serverlesstf.md)
+ [Amazon SAM CLI with Terraform reference](terraform-reference.md)
+ [What is Amazon SAM CLI support for Terraform?](#what-is-terraform-support)

## What is Amazon SAM CLI support for Terraform?
<a name="what-is-terraform-support"></a>

Use the Amazon Serverless Application Model Command Line Interface (Amazon SAM CLI) with your Terraform projects or Terraform Cloud to perform local debugging and testing of:
+ Amazon Lambda functions and layers.
+ Amazon API Gateway APIs.

For an introduction to Terraform, see [What is Terraform?](https://developer.hashicorp.com/terraform/intro) at the *HashiCorp Terraform website*.

To provide feedback and submit feature requests, create a [GitHub Issue](https://github.com/aws/aws-sam-cli/issues/new?labels=area%2Fterraform).

**Note**  
As part of the parsing step of Amazon SAM CLI's integration, Amazon SAM CLI processes user commands generate project files and data. The command output should remain unchanged, but in certain environments, the environment or runner may inject additional logs or information in the output.

**Topics**
+ [What is the Amazon SAM CLI?](#what-is-terraform-support-sam-cli)
+ [How do I use the Amazon SAM CLI with Terraform?](#what-is-terraform-support-how)
+ [Next steps](#what-is-terraform-support-next)

### What is the Amazon SAM CLI?
<a name="what-is-terraform-support-sam-cli"></a>

The Amazon SAM CLI is a command line tool that you can use with Amazon SAM templates and supported third-party integrations, such as Terraform, to build and run your serverless applications. For an introduction to the Amazon SAM CLI, see [What is the Amazon SAM CLI?](what-is-sam-overview.md#what-is-sam-cli).

The Amazon SAM CLI supports the following commands for Terraform:
+ `sam local invoke` – Initiate a one-time invocation of an Amazon Lambda function resource locally. To learn more about this command, see [Introduction to testing with sam local invoke](using-sam-cli-local-invoke.md).
+ `sam local start-api` – Run your Lambda resources locally and test through a local HTTP server host. This type of testing is helpful for Lambda functions that are invoked by an API Gateway endpoint. To learn more about this command, see [Introduction to testing with sam local start-api](using-sam-cli-local-start-api.md).
+ `sam local start-lambda` – Start a local endpoint for your Lambda function in order to invoke your function locally using Amazon Command Line Interface (Amazon CLI) or SDKs. To learn more about this command, see [Introduction to testing with sam local start-lambda](using-sam-cli-local-start-lambda.md).

### How do I use the Amazon SAM CLI with Terraform?
<a name="what-is-terraform-support-how"></a>

The [core Terraform workflow](https://developer.hashicorp.com/terraform/intro/core-workflow) consists of three stages: **Write**, **Plan**, and **Apply**. With Amazon SAM CLI support for Terraform, you can take advantage of the Amazon SAM CLI `sam local` set of commands while continuing to use your Terraform workflows to manage your applications on Amazon. Generally, this means the following:
+ **Write** – Author your infrastructure as code using Terraform.
+ **Test and debug** – Use the Amazon SAM CLI to locally test and debug your applications.
+ **Plan** – Preview changes before applying.
+ **Apply** – Provision your infrastructure.

For an example of using the Amazon SAM CLI with Terraform, see [ Better together: Amazon SAM CLI and HashiCorp Terraform](https://amazonaws-china.com/blogs/compute/better-together-aws-sam-cli-and-hashicorp-terraform/) at the *Amazon Compute Blog*.

### Next steps
<a name="what-is-terraform-support-next"></a>

To complete all prerequisites and set up Terraform, see [Getting started with Terraform support for Amazon SAM CLI](gs-terraform-support.md).