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
-
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 ofhello
could be different (if I changed the handler implementation before deploying), basically, just like what serverless framework does.when deploy,
STAGE=dev cdk synthesize
thenSTAGE=dev cdk deploy
STAGE=stage cdk synthesize
thenSTAGE=stage cdk deploy
It 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 theid
is different, this is a new resource, why should I bother use thisaddVersion
in the 1st place? So, a bit confused herethis is simplified code, in my app, I pass the
process.env.STAGE
from theprops
parameter, and use this flow, even though it works, I found a problem with this approach, so, when I runcdk stack
,App-stage
will 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