How can I copy config between different projects? ...
# general
How can I copy config between different projects? I've renamed the project by exporting and importing the stack, now I'd like to also copy the config to the new project, how can I do it? I tried
Copy code
pulumi config cp --stack staging  --dest <owner>/dest-proj/staging
I get
error: [400] Message authentication failed
Do you have the correct access on the new stack? Does the new stack exist?
Also, are you actually copying it from one stack to another if you've renamed the old one?
yes I can see both projects and their stacks in pulumi console I resolved the error by
pulumi config refresh
in old project however now the command can pass without any result
I can now that encrpyted config values depend on the directory where the
command is run from in my current structure
Copy code
Copy code
cd new_proj
pulumi config --show-secrets  # empty as expected

cd old_proj
pulumi config --show-secrets # returns values

cd ..  # back to new_proj
pulumi config --show-secrets -C old_proj  # error 400 auth failed

pulumi config refresh -C old_proj 
pulumi config --show-secrets -C old_proj  # returns values
however none of the commands above helped to resolve the issue with copying the config:
Copy code
cd new_proj

pulumi config cp --dest owner/new_proj/staging -C old_proj
-v 3
does not give any debug log
I seem to be confused from stack names and organisations
if I understand it correctly the naming is
however on the website there is one more box
is the repository - does this play any role in the naming? what would be the actual name of the project and stack inside? I have a project called
there with stack
Is the fully qualified name:
or is it
? Or something completely different because some other projects are created directly in my namespace
Hmm in the end I managed to do it using automation api:
Copy code
from pulumi import automation as auto

owner = 'owner'

new_project_name = "new_proj"
new_stack_name = f"{new_project_name}/staging"
old_project_name = "old_proj"
old_stack_name = f"{old_project_name}/staging"
new_stack = auto.select_stack(
    stack_name=f"{owner}/{new_stack_name}", project_name=new_project_name, program=lambda: ""
old_stack = auto.select_stack(
    stack_name=f"{owner}/{old_stack_name}", project_name="does not matter", program=lambda: ""


# update project config namespace
new_config = {k.replace(f"{old_project_name}:", f"{new_project_name}:"): v for k, v in old_stack.get_all_config().items()}

# update new stack