This message was deleted.
# getting-started
s
This message was deleted.
c
You'd probably need to use Automation API if you need to inject some external inputs during a stack build. https://www.pulumi.com/docs/guides/automation-api/
r
Hmm, I don't want to do that in this case and lose out on the CLI tools. I was hoping to convert over some terraform/serverless files to pulumi, but might wait until running shell commands is better supported. I appreciate your help
c
You could just wrap it in a shell script
p
I’ve never done it but I guess you should be able to run shell commands in pulumi script without any issues. Not sure if it’s a recommended approach though.
c
More like:
Copy code
#!/usr/bin/env bash

git rev-parse --abbrev-ref HEAD
pulumi config ...
pulumi up
ls -altr
p
that seems like a better option - modify the config before running
pulumi up
so the change is actually reflected in the source code and/or in config values
another option is to directly invoke the command in pulumi code itself like:
Copy code
import pulumi_gcp as gcp
import subprocess

shell_result = subprocess.check_output(["uname", "-r"], text=True).strip()
bucket = gcp.storage.Bucket(
    "test",
    name=shell_result,
)
But I guess @crooked-pillow-11944 approach is better. The above will be non deterministic from my point of view. It can give different outputs every time it’s being run and it leaves no trace in source code/config values. Anyway, if this is something you used to do with terraform, here you go. I wouldn’t say pulumi has worse support for shell commands. It’s exactly the opposite 😄 You can do everything python/javascript/C#/go can do.
r
I like the idea of passing in shell command output via config files, that should be a nice solution I think