Slide 24
Slide 24 text
💡 解決方法: コード紹介
// ApiDeploymentStack
export class ApiDeploymentStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: ApiDeploymentStackProps) {
// api-stackで定義したAPI Gateway
const apiGateway = RestApi.fromRestApiAttributes(this, "api", {
restApiId: props.apiId,
rootResourceId: props.rootId,
});
// Deploymentを定義
const deployment = new Deployment(this, "base-api-deployment", {
api: apiGateway,
retainDeployments: true,
});
deployment.addToLogicalId(new Date().toISOString()); //
⭐️ Deploymentを更新
// Stageを定義し、deploymentを紐づける
const stage = new Stage(this, "base-api-stage", {
deployment,
stageName: "prod",
});
}
}
15