What is the AWS way to add stage with @aws-cdk/aws-apigatewayv2 and @aws-cdk/aws-lambda-nodejs
#14993
Unanswered
Albert-Gao
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Googled so hard, finally figured out a way, want to verify if this is the idiomatic AWS way,
basically, I want to do something like: for an API Gateway route "/hello", connect it with lambda handler
hello, and deploy dev/stage/prod version according to the environment variable, and the dev/stage version ofhellocould be different (if I changed the handler implementation before deploying), basically, just like what serverless framework does.when deploy,
STAGE=dev cdk synthesizethenSTAGE=dev cdk deploySTAGE=stage cdk synthesizethenSTAGE=stage cdk deployIt created 2 versions of API gateway linked to 2 versions of lambda, all works fine
is this the suggested way? I found a
handler.currentVersion.addVersion()method, but seems it needs to assign to a handler with different id, but if theidis different, this is a new resource, why should I bother use thisaddVersionin the 1st place? So, a bit confused herethis is simplified code, in my app, I pass the
process.env.STAGEfrom thepropsparameter, and use this flow, even though it works, I found a problem with this approach, so, when I runcdk stack,App-stagewill not show up, butApp-dev, maybe because I set the stage default todev.this problem cause me wonder: am I doing it right? What am I missing here.
Beta Was this translation helpful? Give feedback.
All reactions