This question isn't really specific to typescript,...
# typescript
This question isn't really specific to typescript, but that's what i'm using for my project. I am looking for a way to either detect at runtime that a resource will be updated, or just create a dependent resource that will always replace when its source resource is updated. The former would be good enough, but the latter is what i'm trying to accomplish.
Hi Johnny, if you mean you want to encode a dependency between two resources in your program, would
achieve what you want?
based on my testing, that doesn't cause dependent resources to be replaced when upstream resource is updated. just affects order. is that not correct?
Ah I see -- when you say "source resource", you mean the actual cloud resource. So when that changes, you want Pulumi's state to be updated, is that right?
I don't believe there's a way to do what you want "in program" right now, though there is
pulumi refresh
, which instructs Pulumi to look at all cloud resources and update its state accordingly
not refresh, no. imagine 2 resources. i update some property of resource 1, causing pulumi to determine that resource needs to be updated. i'd like resource 2 in this case to be replaced, though none of its properties changed. does that make sense?
it would be enough if i could do something like:
Copy code
const resource1 = new aws.Resource("resource1", { property: value })
if (resource1.isDirty()) {
    // force resource2 to update
though i can't find any such runtime method to determine that resource1 is set to be updated
Hm indeed I'm not sure there's a way to do this neatly at present 🤔
neatly is not a requirement thankfully 🙂
i'm down to kludge
Well, currently I'm struggling to do it at all 😂
that's what i was worrying
I know for e.g.
there is
but that is specific to that resource
just gonna have to keep manually updating the description for the dependent resource. definitely introduces a heap of human error risk, but oh well
There is Pulumi Automation, but obviously that's a chunk of work
To force a replace (delete & recreate) I think you're looking for the replaceOnChanges resource option. There is a downside which is that some input to the dependent resource must depend on the first. Is it not possible to have Resource2's description be defined as an input property, derived from Resource1's outputs? Making these two resources concrete would be helpful, are they resources in AWS, elsewhere?
you could make some resources "reactive" with
method which is not properly documented here:
is definitely the surface area i'm looking to attack. but apart from doing something really heavy handed like sha-ing the entire configuration for
and injecting the hash in to the description field for
or whatever, there is no mechanism i can devise to ensure that the
field i'm targeting updates if and only if
will be created or updated
It would be helpful to make this example a bit more concrete - what is it we're trying to accomplish by destroying and recreating Resource B?
resourceA is an aws lambda, and resourceB is a lambda version. this is only an issue with
publish: true
directly on the lambda resource which works great. but with
, the lambda and lambda version being 2 separate resources means it only publishes the initial version, then does not create a new version unless the version resource itself is updated, whereas i need a new version to be created every time any property of the lambda changes (an environment variable, say)
Ah, that makes sense - that seems like a bug in the AWS native provider and a weird quirk. So on the
you pass it in a changing zipFile or other code, but it is a separate
resource that creates a new instance using the current code of the lambda. Would you be able to switch to using the
package's lambda function? It seems like it'll be better behaved. In the mean time I'll flag this issue with the providers team that owns AWS Native for them to create an issue.
@shy-whale-9556 I conferred with some folks on the team and we recommend using
instead of the AWS Native implementation, as it does what you want on handling version updates. The AWS Native provider implements the CloudControl & CloudFormation API from AWS, and in this case it results in a very hard to use set of resources.