https://pulumi.com logo
#general
Title
# general
b

bored-table-20691

01/24/2022, 6:27 PM
I’m seeing some behavior I don’t understand with
local.Command
. Here is my entire Pulumi program:
Copy code
package main

import (
	"<http://github.com/pulumi/pulumi-command/sdk/go/command/local|github.com/pulumi/pulumi-command/sdk/go/command/local>"
	"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {

		_, err := local.NewCommand(ctx, "test", &local.CommandArgs{
			Create: pulumi.String("./create.sh hello"),
			Delete: pulumi.String("./destroy.sh goodbye"),
			Environment: pulumi.StringMap{
				"foo":  pulumi.String("bar"),
			},
		})
		if err != nil {
			return err
		}

		return nil
	})
}
Here is `create.sh`:
Copy code
#!/bin/bash

echo "hello: $1" >> /tmp/pulumi_log.txt
and `destroy.sh`:
Copy code
#!/bin/bash

echo "goodbye: $1" >> /tmp/pulumi_log.txt
When I run
pulumi up
the first time, I get the
hello: …
in the log file. If I run
pulumi destroy
, I get the
goodbye: ...
in the log file. However, if I were to change the
environment
, nothing happens, the script does not seem to execute at all (nothing gets added to the log file. Is this expected? Am I doing something wrong?
FWIW, this happens with both Pulumi 3.4.0 and 3.22.1 (the latest), no difference.
Updates are currently no ops unless there is a replacement
b

bored-table-20691

01/24/2022, 7:07 PM
What constitutes a replace in this case? It seems like just updates to inputs (e.g. environment or other dependencies) won’t have any impact, so it won’t get replaced?
s

sparse-park-68967

01/24/2022, 7:10 PM
As defined by default just changing the name etc. would trigger a replace I believe. You could trigger the replace by adding a
replaceOnChanges: ["environment"]
option on the resource
b

bored-table-20691

01/24/2022, 7:13 PM
I see. Definitely not what I expected, probably worth a quick doc note in the README 🙂
And if I have it correct, there’s no way to do an update today, correct? It’ll always be a delete/create cycle.
s

sparse-park-68967

01/24/2022, 7:20 PM
That is my understanding. Perhaps we need an update hook as well? Feel free to open a feature request on the repo to start that conversation if you feel like you have a good use case.
b

bored-table-20691

01/24/2022, 7:22 PM
FWIW, I opened an issue on my first thing, which I’ll update with the discussion here.
I’m adding a comment with my findings/thoughts too (just saw yours too)
👍 1
Done, thank you.
5 Views