Skip to content
GitHubXDiscord

Deployment

The Deployment resource lets you manage AWS ApiGatewayV2 Deployments to create and deploy APIs in AWS. This resource facilitates versioning for API changes and allows you to manage your API lifecycle effectively.

Create a basic deployment for an API with a description and a stage name:

import AWS from "alchemy/aws/control";
const apiDeployment = await AWS.ApiGatewayV2.Deployment("myApiDeployment", {
ApiId: "abc123def456",
Description: "Initial deployment of my API",
StageName: "prod"
});

Configure a deployment with additional properties such as adopting existing resources:

const advancedApiDeployment = await AWS.ApiGatewayV2.Deployment("myAdvancedApiDeployment", {
ApiId: "abc123def456",
Description: "Advanced deployment with existing resource adoption",
StageName: "staging",
adopt: true
});

Demonstrate how to rollback to a previous version of an API by creating a new deployment for the existing API:

const rollbackDeployment = await AWS.ApiGatewayV2.Deployment("myRollbackDeployment", {
ApiId: "abc123def456",
Description: "Rolling back to previous API version",
StageName: "prod"
});

Create a deployment that includes monitoring settings for better observability:

const monitoredApiDeployment = await AWS.ApiGatewayV2.Deployment("myMonitoredApiDeployment", {
ApiId: "abc123def456",
Description: "Deployment with monitoring enabled",
StageName: "prod",
adopt: false // Not adopting existing resources for fresh deployment
});