This message was deleted.
# general
s
This message was deleted.
s
Create 2 resources, each with 1 provider, rather than 1 resource with 2 providers.
But more importantly, I think you actually want a dev and prod stack rather than 1 stack with 2 providers.
Something like:
Copy code
pulumi stack init dev
pulumi config set aws:region us-east-1
pulumi stack init prod
pulumi config set aws:region us-west-2
pulumi stack select dev
# write your program
pulumi up # deploy to dev
pulumi stack select prod
pulumi up # deploy to prod
Also note that Pulumi will auto-name your resources so that you can deploy the same stack into the same account/region.
m
I know creating two resources is one solution but I am looking if there is anyway to create the same resource with two providers.
I am not using the same name (xyz is just for chat).
I know creating two stacks but requirement here is different. First this stack is actually not part of prod/dev. Second I need to replicate the buckets so I want to keep the name almost same.
s
The autonaming will still be human-readable, but will have a hex hash on the end, e.g. "my-bucket-5489ae"
m
Yes, and I am okay with that.
s
And no, you can't create the same resource with 2 providers. That's actually 2 resources. BUT... you're using a real programming language, so you can use a loop!
The provider is part of what uniquely identifies a resource. 2 different providers, e.g. in 2 regions, is 2 actual buckets.
m
Ok so you mean there is no native way like using array or list?
Do you think this can be added a feature requirement?
s
No, because again - that's 2 separate resources.
You could also make a ComponentResource and pass it a provider. (They're analogous to Terraform modules.)
But I would just start with a function or a loop.
m
Ok. Thanks