AWS API Gateway V2 Deployment

This page shows how to write Terraform and CloudFormation for API Gateway V2 Deployment and write them securely.

aws_apigatewayv2_deployment (Terraform)

The Deployment in API Gateway V2 can be configured in Terraform with the resource name aws_apigatewayv2_deployment. The following sections describe 3 examples of how to use the resource and its parameters.

Example Usage from GitHub
resource "aws_apigatewayv2_deployment" "this" {
  api_id      = var.api_id
  description = var.description
  triggers    = var.triggers
resource "aws_apigatewayv2_deployment" "deployment" {
  api_id      =
  description = local.apigw_resource_name

  triggers = {
    redeployment = sha1(join(",", list(
resource "aws_apigatewayv2_deployment" "Deployment" {
  api_id =

  depends_on = [

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).


Explanation in Terraform Registry

Manages an Amazon API Gateway Version 2 deployment. More information can be found in the Amazon API Gateway Developer Guide. -> Note: Creating a deployment for an API requires at least one aws_apigatewayv2_route resource associated with that API. To avoid race conditions when all resources are being created together, you need to add implicit resource references via the triggers argument or explicit resource references using the resource depends_on meta-argument. -> It is recommended to enable the resource lifecycle configuration block create_before_destroy argument in this resource configuration to properly order redeployments in Terraform.

AWS::ApiGatewayV2::Deployment (CloudFormation)

The Deployment in ApiGatewayV2 can be configured in CloudFormation with the resource name AWS::ApiGatewayV2::Deployment. The following sections describe 1 example of how to use the resource and its parameters.

Example Usage from GitHub

      "default" : "AWS::ApiGatewayV2::Deployment"
    "Properties" : {
      "$ref" : "AWS_ApiGatewayV2_Deployment.schema.json"


Explanation in CloudFormation Registry

The AWS::ApiGatewayV2::Deployment resource creates a deployment for an API.

Frequently asked questions

What is AWS API Gateway V2 Deployment?

AWS API Gateway V2 Deployment is a resource for API Gateway V2 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS API Gateway V2 Deployment?

For Terraform, the niveklabs/aws, saragerion/serverless-voting-app and paveg/ppoker source code examples are useful. See the Terraform Example section for further details.

For CloudFormation, the shiver-me-timbers/smt-cloudformation-parent source code example is useful. See the CloudFormation Example section for further details.