Skip to content

Stage

Source: src/AWS/ApiGateway/Stage.ts

A stage for a REST API deployment.

A Stage is what clients actually call. It binds a name (dev, prod, v2) to a specific Deployment of a RestApi and exposes it at a stable URL:

https://<restApiId>.execute-api.<region>.amazonaws.com/<stageName>/
const stage = yield* ApiGateway.Stage("Dev", {
restApi: api,
stageName: "dev",
deploymentId: deployment.deploymentId,
});
const stage = yield* ApiGateway.Stage("Prod", {
restApi: api,
stageName: "prod",
deploymentId: deployment.deploymentId,
variables: {
logLevel: "info",
featureFlag: "on",
},
});

Point canarySettings at a different Deployment to split traffic between the stable and canary versions. percentTraffic is the percent of requests routed to the canary deployment.

const stage = yield* ApiGateway.Stage("Prod", {
restApi: api,
stageName: "prod",
deploymentId: stableDeployment.deploymentId,
canarySettings: {
percentTraffic: 10,
deploymentId: canaryDeployment.deploymentId,
},
});