【发布时间】:2021-05-28 12:57:11
【问题描述】:
我正在使用 AWS CDK 来管理我的 API Gateway 的部署。我使用阶段通过环境来推广我的代码,例如开发、测试、预生产、生产。我的脚本看起来像这样:
export class MyStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const api = new apigateway.SpecRestApi(this, 'my-api', {
deploy: false,
apiDefinition: apigateway.ApiDefinition.fromAsset('path/to/swagger.yaml'),
});
const stageName = this.node.tryGetContext('stageName');
const deployment = new apigateway.Deployment(this, `my-api-deployment-${stageName}`, { api });
new apigateway.Stage(this, `my-api-stage-${stageName}`, {
stageName,
deployment,
});
}
}
不幸的是,当我将代码从一个阶段提升到下一个阶段时,例如cdk deploy --context stageName=PREPROD,之前的阶段被删除了,所以我的 API 网关中只有一个阶段。
是否可以在不删除其他阶段的情况下部署到一个阶段?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation aws-api-gateway aws-cdk