Hi, I'm trying to understand how to work efficient...
# general
Hi, I'm trying to understand how to work efficiently with Pulumi in multiple accounts. Currently, I have two different projects that must be non-related, so when I'm in directory of the first project,
, I just need to type
pulumi up
and that's it, and when in the other project's directory,
- the same: just type
pulumi up
and that's it. But it's not convenient, because I must always run
pulumi logout
, then
pulumi login
to switch from one project to the other (as they are managed in different Pulumi accounts). In Terraform it's very simple: the
is bound to a specific AWS account and managed there, so everything is local: I just run
terraform apply --var-file=dev.tfvars
provider aws { profile = var.profile ...
binds it to the right profile / account. Do you have any idea how to make it simple as that in Pulumi too? Is it possible to keep all "login" / "profile" info located in the project directory and not having to switch accounts again and again?
There's a
value you can add to your project configuration that might help. More details here: https://www.pulumi.com/docs/concepts/state/
Is the backend what's presenting the problem here, or are you trying to get the aws.Provider instance in each project to be completely unrelated? If it's the latter, then I recommend disabling default providers and creating the provider explicitly in each project. It means you'll need to pass it into every resource constructor, but it allows you to guarantee that the projects never intrude into each other's accounts.
@little-cartoon-10569 I'm not 100% sure that I understand your question, but I get it right, that I'm referring to the Pulumi account, not the (AWS) provider. The provider is solvable, as I can write in the project file (the
file) the name of the AWS provider e.g.:
Copy code
  aws:profile: specific_profile_name
@salmon-account-74572 thanks! exactly what I was looking for! 😊 I ended up using this for local dev stages:
Copy code
  url: file://.
and I believe that
url: s3://...
will fit when we advance
Perfect, glad I was able to help!
If configuring the aws:profile setting is fixing the problem, then the backend fix is solving the problem as a side effect. It's a good fix to prevent repeated calls to
pulumi login
. Which AWS account (and indeed, region) you are using is defined by instances of aws.Provider: account is Provider. You should probably read up on that class and what it can do. It will help you avoid similar problems in the future. https://www.pulumi.com/registry/packages/aws/api-docs/provider/