https://pulumi.com logo
Title
s

stocky-magazine-78486

08/18/2021, 12:11 PM
Hi, (newbie question maybe), I use Pulumi to create dynamodb table. Now it auto-renames by appending a random number to my db name. I know it can be avoided by providing “name” field, but without that, how can I access the random generated table name from within my lambda?
w

wet-fall-57893

08/18/2021, 12:43 PM
you can reference it via code if they are in the same codebase.
const db = new aws.dynamodb.Table(...)
//reference it
db.arn
if not, you could possibly export db from stack A as stack output and import it from stack B where your lambda is. https://www.pulumi.com/docs/intro/concepts/stack/#stackreferences That said, it’s always a good practice to specify name where possible. Note some resources might not have
name
available.
s

stocky-magazine-78486

08/18/2021, 1:30 PM
Hi @wet-fall-57893 yes they are in same codebase and part of same stack. Are you saying, I can hardcode the random table name generated?
db.arn
can only be accessed within the pulumi typescript file right
?
w

wet-fall-57893

08/18/2021, 11:38 PM
set it as ENV var so that you can access it from within your lambda handler
s

stocky-magazine-78486

08/19/2021, 2:03 AM
Thanks @wet-fall-57893, that makes me curious, is there a way to configure Env variables on Lambda functions directly from Pulumi during deployment itself?