It seems like all of the properties are marked as ...
# aws
e
It seems like all of the properties are marked as
read-only
and I can’t alter them, which means that the only way I can change them is by re-creating a lambda and copy all of the settings… Why doesn’t pulumi allow changes to resources? By not doing so, it becomes immensely painful to create wrappers around common workflows such as
SQS -> Lambda
pattern.
b
Pulumi does allow changing properties on a resource, but it drives to a desired state. If you update your lambda resource with environment variables it should get created with them. I’m a little confused about what you mean by copying the lambda, can you share some code You’re using?
e
@billowy-army-68599 sure. What I mean is that in one place I execute the
const foo = new aws.lambda.CallbackFunction(…)
and somewhere else I want to change that callback’s environment variables:
foo.environment.variables = merge(foo.environment.variables, {foo: 'bar'})
This isn’t possible to do, at least with the
ts
version of Pulumi. Maybe we can do it, but the errors are all over
b
When you say somewhere else, do you mean another Pulumi program?
Or on another resource?
e
on another file in my specific case
What I’m trying to build is an abstract of a Queue -> Lambda sequence
There is a Queue at the beginning of the flow and from there is a lambda that processes messages and sends new messages to other queues
since we have many flows like this, I want to abstract the connecting logic away and provide a nice fluent way to defining the chain
b
You can’t do this, Pulumi doesn’t have “flow”. It’s imperative code but Pulumi is a declarative tool. Every resource In your program gets built and created at the same time, so assigning variables further down the flow sounds like you’re building imperative code, which just isn’t possible, it’s not how Pulumi is designed to work
e
Why isn’t possible? My current workaround is to create a custom class that receives the same arguments as the original Lambda class and defer the initialization of that lambda until I need it
since I’m now the “owner” of the data, I can just use it wherever I want
b
You can keep deferring the creation of resources via the asynchronous capabilities of JavaScript but ultimately you’re going to keep running into these issues I’m afraid
e
I see. Thanks @billowy-army-68599! So far it’s looking fine. Will have to keep monitoring this I guess