https://pulumi.com logo
#aws
Title
# aws
t

thousands-area-40147

08/26/2021, 4:42 PM
Hej everyone! Using Typescript, how would I go about using pulumi-specific types in Lambda functions? Naively importing them in the same way you would with custom defined types results in the
Cannot find module '@pulumi/pulumi/runtime/index.js'
error, I guess because
@pulumi/...
packages are not included in the Lambda. Any way around this?
l

little-cartoon-10569

08/26/2021, 9:19 PM
Short of installing Pulumi in the lambda, no. What types do you want to use in a lambda? There may be a different way to achieve your goals.
t

thousands-area-40147

08/26/2021, 9:22 PM
I'm passing a TopicEvent to a Lambda function to process it further. There are workarounds (
JSON.stringify()
e.g.), but it'd be nice to keep the proper types, if at all possible
l

little-cartoon-10569

08/26/2021, 9:26 PM
The event arrives in the lambda as a JSON payload, I believe? There's a class in the AWS SDK you could use, but since it's not a Pulumi object, there's no need to bring Pulumi into the equation, I think?
Ah I see the TopicEvent/TopicRecord stuff in the mixins. I guess you could copy that code, it's pretty lightweight. But using the SDK equivalents is probably best.
t

thousands-area-40147

08/26/2021, 9:32 PM
Copying the code is what I've went with for now, but thanks for the hint, will look for the SDK versions : )
👍 1
w

white-balloon-205

08/27/2021, 3:54 PM
If you are just using the types, this should work just fine, as they are only used at TypeScript build time. Can you perhaps share a snippet of the code you are using inside your CallbackFunction, and how you are using
TopicEvent
?
1
t

thousands-area-40147

08/28/2021, 4:03 PM
Checked again and you are right! The issue was passing a parameter with
pulumi.Config().require()
without storing it as an intermediary variable.
👍 1
2 Views