我已经有一个包含资源和阶段的API网关。我通过aws cdk向其中添加了一个新的资源。该网关配置为deploy:false,因此我必须手动创建新的部署。我可以导入这个网关,但是我找不到 Stage 类中类似于 fromLookup 的方法。我知道我可以创建一个新的阶段,但这似乎不是可扩展的解决方案。
以下是代码:
以下是代码:
const api = apigateway.RestApi.fromRestApiAttributes(this, 'RestApi', {
restApiId: 'XXX',
rootResourceId: 'YYYY',
});
const deployment = new apigateway.Deployment(this, 'APIGatewayDeployment', {
api,
});
// How to get an existing stage here instead of creating a new one?
const stage = new apigateway.Stage(this, 'test_stage', {
deployment,
stageName: 'dev',
});
api.deploymentStage = stage;
(deployment as any).resource.stageName = 'YourStageName';
。 - samuba