https://pulumi.com logo
#getting-started
Title
# getting-started
r

ripe-xylophone-26538

03/12/2024, 3:45 PM
Hey, once again: Does anybody know how I can generate a yaml-template with secrets that I am getting from config?
Copy code
from pulumi import Config

password = config.require_secret("password")

def read_config(tpl, substitutes):
    with open(tpl, "r") as template:
        yml = template.read()
        yml = string.Template(yml)
        yml = yml.substitute(substitutes)
        sp = subprocess.run(["butane"], input=yml, shell=True, capture_output=True, encoding='utf8')
        if sp.returncode == 0:
            return str(base64.b64encode(sp.stdout.encode('ascii')), encoding='ascii')
        else:
            log.error('Failed to run butane')

print(read_config("tpl.yaml", {"password": password})
Is this even possible with Pulumi? Do I have to work around Pulumi here? I am seeing no way around this? I was trying
.apply
but I never get my password anywhere as plain text...
Screenshot 2024-03-12 at 17.09.09.png
r

ripe-xylophone-26538

03/13/2024, 7:26 AM
Thank you!
Just one question... Is it necessary to use
yaml.dump
for that? I just want to feed the yaml as string into the pulumi vm resource and don't need a file for that? Just seeing that it does not work straightforward with my code above. (Sorry, noob in python). Anything preventing me from using the
read_config
as above?
ok, got it working
thanks