Skip to content

(aws-lambda-nodejs): Node.js build fails with stack dependency #19704

Answered by jogold
spdolan asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @spdolan

What are you trying to achieve here exactly?

The queueUrl is a deploy time value, it is only known after the queue stack is deployed. During synth it is represented by a token this is why you see ${Token[TOKEN.209]}. During synth/bundling those values are not resolved yet.

What you can do is pass the queueUrl as a runtime environment variable to your Lambda function.

new lambda.NodejsFunction(this, 'MyFn', {
  environment: {
    QUEUE_URL: props.queueUrl,
  }
});

Now you can use process.env.QUEUE_URL in your code and when the Lambda runs it will have the correct value.

Also note that you don't need a toString() in your queue stack. And you can also pass the queue object betwee…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@hugomallet
Comment options

@jogold
Comment options

@hugomallet
Comment options

Answer selected by indrora
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. @aws-cdk/aws-lambda-nodejs
4 participants
Converted from issue

This discussion was converted from issue #19561 on April 01, 2022 18:43.