This message was deleted.
# python
s
This message was deleted.
b
Or maybe I can somehow encapsulate that function into a Pulumi resource that depends on the pipeline?
I have also tried with a custom class that depends on the pipeline, but the init method is always executed. And I want it to be executed only if there's a change in the pipeline:
Copy code
class MyAMI(pulumi.ComponentResource):
        def __init__(self, name, opts=None):
            super().__init__(
                "pkg:example:AMI", name, props={}, opts=opts,
            )
            child_opts = pulumi.ResourceOptions(parent=self)

            with open("/tmp/pulumi.log", "a") as file:
                file.write("Running pipeline")
Okay, I can pass the pipeline to that new class and make the instance dependent on it. But what about if I need to run some python code only if the pipeline has been executed? For example that
with open
statement
s
https://pulumi-developer-docs.readthedocs.io/en/latest/architecture/overview.html#resource-providers Not sure how to conditionally drive the ec2 creation programmatically since the declarative nature of Pulumi seems to first want to understand the full tree of resources to build, then it fires the dependency tree to another process to create everything But maybe you meant https://www.pulumi.com/docs/concepts/options/dependson/ I use that in conjunction with https://www.pulumi.com/docs/concepts/options/parent/ so the deps tree looks nicer on
pulumi up
I find that it helps to think of how pulumi programs work as "yaml", if you can't do it in yaml, you can't do it pulumi, generally speaking
b
Thanks for the response @straight-cartoon-24485. I'm finally going to use dynamic providers since it seems that they allow me to create my custom code when the resource is created/changed/deleted
👍 1