So, I cam across a lot of threads, but none of them solved my problem.
I am trying to deploy Lambda functions to an existing RestApi with an existing DEV-Stage. My API is build like this:
this.RestAPIDev = new gw.RestApi(this, 'StagingGatewayDev', {
restApiName: 'gateway-DEV',
deploy: true,
deployOptions: {
stageName: 'DEV',
description: 'DEV Stage',
variables: { ALIAS: 'DEV' },
}
});
The Lambda Stack is separated in its own repository including a pipeline and the lambda code. I am trying to deploy these Lambda functions to this existing gateway by adding resources and methods and assume that because i set deploy:true
on the gateway, it will get deployed by itself.
So here is the Lambda Stack:
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, {}),
);
But no update on the Stage Tab...
I have also tried the solution to create a new Deployment and Stage, but got the error that this stage already exists (Sure I know). I also tried to create a new Deployment and add deployment.resources.stageName
to it, but this isn't available for my CDK version.
Any clue on this?
Thanks in advance!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…