I have a question for the more experienced .. for ...
# getting-started
I have a question for the more experienced .. for
.. at which point is
run? Obviously it runs when I add it, but is there any other part of the life cycle I can make it run? I need a hook to run DB migrations, so it's something I'd like to have fire off every time I do a
pulumi up
I'm no expert, but it seems like what you want is the
parameter? You can set it to something like
so that it triggers and
on each run. I.E.
Copy code
const myCommand = new command.local.Command("my-command", {
    create: "echo 'Hello, Pulumi!'",
    // Use the timestamp as the working directory
    // This effectively forces the Command to run on every `pulumi up` since
    // the `triggers` argument will be different every time
    triggers: [timestamp.toString()],
Ah, thanks Alex,.. that would definitely have the effect of what I want do. That's going to effectively "recreate" that command every time? so I wonder what `update`is really that useful for?
That's going to effectively "recreate" that command every time?
Yes, I believe so. I suppose
can be useful for things like when changing the command being run (for example, adding an environment variable?)
Cool; thanks for the insight. I'll play around with it.
I believe if you have an update script it will run instead of the create script whenever the command is triggered to run again (whether it’s from a trigger or from the script(s) being changed)
if you have a complex script that you keep changing over the lifetime of running deployments it ends up being a bit clunky (you’ll have to keep modifying both create and update in order to have both working existing deployments and a working initial create script), but it is possible at least
I see. Yah, the script itself is idempotent (e.g. it runs DB migration tools).. so I just need it to run every time. For now I just went with Alex's suggestion and have it always running against an updated timestamp.
You can also use https://www.pulumi.com/registry/packages/command/api-docs/local/run/ to run a command every time.