【发布时间】:2021-04-17 06:06:39
【问题描述】:
所以,我遇到了很多线程,但没有一个能解决我的问题。 我正在尝试将 Lambda 函数部署到具有现有 DEV 阶段的现有 RestApi。我的 API 是这样构建的:
this.RestAPIDev = new gw.RestApi(this, 'StagingGatewayDev', {
restApiName: 'gateway-DEV',
deploy: true,
deployOptions: {
stageName: 'DEV',
description: 'DEV Stage',
variables: { ALIAS: 'DEV' },
}
});
Lambda 堆栈在其自己的存储库中分离,包括管道和 lambda 代码。我正在尝试通过添加资源和方法将这些 Lambda 函数部署到这个现有网关,并假设因为我在网关上设置了deploy:true,它将自行部署。
所以这里是 Lambda 堆栈:
const restApi = gw.RestApi.fromRestApiAttributes(this, 'RestApi', {
restApiId: props.restApiId,
rootResourceId: props.restApiRoot,
});
const authenticate = new lambda.Function(this, 'AuthenticateFunction', {
code: this.lambdaCode, // is a property
runtime: lambda.Runtime.NODEJS_12_X,
handler: 'src/api/authenticate.handler',
description: 'API: Authenticates the token',
role: <executionRole>, // is a property
});
const authenticateAlias = new lambda.Alias(this, 'AuthenticateAlias', {
aliasName: 'DEV',
version: new lambda.Version(this, 'AuthenticateVersion', {
lambda: authenticate,
}),
});
restApi.root.addResource('authenticate').addMethod(
'POST',
new gw.LambdaIntegration(authenticateAlias, {}),
);
但舞台选项卡上没有更新...
我也尝试了创建新部署和阶段的解决方案,但收到此阶段已存在的错误(我当然知道)。我还尝试创建一个新的部署并向其中添加 deployment.resources.stageName,但这不适用于我的 CDK 版本。
这有什么线索吗?
提前致谢!
【问题讨论】:
标签: typescript aws-cdk api-gateway