How do you set config on a remote Git stack using the python pulumi automation api?

53 views Asked by At

Using the pulumi python automation library I'm trying to create or select a remote stack in Git bring it up. But before I do that I would like to set some config keys.

How do I achieve this?

Tried below but RemoteStack does not have a set_config method

stack_name = auto.fully_qualified_stack_name(org, project, f"{env_id}")
stack = auto.create_or_select_remote_stack_git_source(
    stack_name=stack_name,
    url=f"https://repo.git",
    branch="refs/heads/master",
    project_path="folder_name"
)

# this doesn't work since RemoteStack does not have this method
# stack.set_config("env:id", ConfigValue(value="value", secret=False))

up_res = stack.up(on_output=print)
print("Update succeeded!")

EDIT

The only way I've managed to do this for now is use the pre_run_commands argument in the RemoteWorkspaceOptions class. But this is not favourable when using with (--)secret variables because these commands become visible in the deployment logs in plain text.

stack_name = auto.fully_qualified_stack_name(org, project, f"{env_id}")
stack = auto.create_or_select_remote_stack_git_source(
    stack_name=stack_name,
    url=f"https://repo.git",
    branch="refs/heads/master",
    project_path="folder_name",
    opts=auto.RemoteWorkspaceOptions(
       pre_run_commands=[
          f'pulumi stack select {stack_name}',
          f'pulumi config set env:id {value}'
       ]
    )
)

# this doesn't work since RemoteStack does not have this method
# stack.set_config("env:id", ConfigValue(value="value", secret=False))

up_res = stack.up(on_output=print)
print("Update succeeded!")
0

There are 0 answers