Hi All, Is there a way in pulumi to have stacks u...
# general
b
Hi All, Is there a way in pulumi to have stacks use a different backend_url without having to pulumi login manually before running the stack? Our scenario: We are using S3 as our state option and currently have an AWS account hosting the bucket. We are setting up a AWS govcloud instance that requires state buckets to be separated. The solution is already built and deployed into a non-gov aws account structure. We are hoping to avoid manual logins, previously we were using the backend option at the project level but that does not work at the stack level. Thanks for the assistance!
h
I'm no expert, but I'm using the S3 backend and I never call pulumi login at all. I just have this in Pulumi.yaml:
Copy code
backend:
  url: <s3://MY_BUCKET_NAME/MY_STACK_NAME?region=us-west-2&awssdk=v2>
I just did a test of moving this to the Pulumi.STACKNAME.yaml and it worked fine.
b
Maybe because you are already logged in to the stack? Try making another stack with a different bucket as the backend.
h
I went to build a test project for this and was surprised to find that it still used the existing backend of other projects (no doubt because that is where I'm "logged in"). It seems that logging in just sets the value of
current
in ~/.pulumi/credentials.json. My guess is that you could just manipulate this file if that helped, but calling login might be the easiest. A couple options to try come to mind... First is setting PULUMI_BACKEND_URL env var in your calls to pulumi. If that doesn't work, you could have a ~/.pulumi/credentials.json and a ~/.pulumi-govcloud/credentials.json and set PULUMI_HOME to point to the one that is logged in to the backend you want.