Skip to content

Resource: awsApigatewayv2Deployment

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 awsApigatewayv2Route 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 dependsOn meta-argument.

-> Enable the resource lifecycle configuration block createBeforeDestroy argument in this resource configuration to properly order redeployments in Terraform.

Example Usage

Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsApigatewayv2DeploymentExample =
  new aws.apigatewayv2Deployment.Apigatewayv2Deployment(this, "example", {
    apiId: "${aws_apigatewayv2_api.example.id}",
    description: "Example deployment",
  });
awsApigatewayv2DeploymentExample.addOverride("lifecycle", [
  {
    create_before_destroy: true,
  },
]);

Redeployment Triggers

-> NOTE: This is an optional and Terraform 0.12 (or later) advanced configuration that shows calculating a hash of the API's Terraform resources to determine changes that should trigger a new deployment. This value will change after the first Terraform apply of new resources, triggering an immediate redeployment, however it will stabilize afterwards except for resource changes. The triggers map can also be configured in other, more complex ways to fit the environment, avoiding the immediate redeployment issue.

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsApigatewayv2DeploymentExample =
  new aws.apigatewayv2Deployment.Apigatewayv2Deployment(this, "example", {
    apiId: "${aws_apigatewayv2_api.example.id}",
    description: "Example deployment",
    triggers: {
      redeployment:
        '${sha1(join(",", tolist([\n      jsonencode(aws_apigatewayv2_integration.example),\n      jsonencode(aws_apigatewayv2_route.example),\n    ])))}',
    },
  });
awsApigatewayv2DeploymentExample.addOverride("lifecycle", [
  {
    create_before_destroy: true,
  },
]);

Argument Reference

The following arguments are supported:

  • apiId - (Required) API identifier.
  • description - (Optional) Description for the deployment resource. Must be less than or equal to 1024 characters in length.
  • triggers - (Optional) Map of arbitrary keys and values that, when changed, will trigger a redeployment. To force a redeployment without changing these keys/values, use the terraformTaint command.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - Deployment identifier.
  • autoDeployed - Whether the deployment was automatically released.

Import

awsApigatewayv2Deployment can be imported by using the API identifier and deployment identifier, e.g.,

$ terraform import aws_apigatewayv2_deployment.example aabbccddee/1122334

The triggers argument cannot be imported.