I am trying to figure out how to set the resource ...
# general
c
I am trying to figure out how to set the resource group for the azure provider. I tried pulumi config set azure:resourcegroup MyResourceGroup but that gave me an error at run time. Spelunking through the provider code has not be helpful either. Any pointers would be appreciated.
s
It tends to be on a per resource basis
(Similar to the Terraform provider)
c
ah ok. So if I want to target a specific resource group I need to take that as a custom config setting and pass it through everywhere.
s
Yes, that’s the case right now
c
ok thanks
s
you can make the RG part of your stack too instead of specifying it as a string
e.g. azure.core.getResourceGroup() or new azure.core.resourceGroup()
s
Right - you could create the resource group and pass it into each resource also (which may be better if you’re working with multiple stacks)
s
then when you do e.g. new keyvault you can specify the rg.name as the resourceGroupName
s
At some point we should go through and allow an
azure.core.ResourceGroup
as an alternative type for each of these
c
ok thanks for the help
s
yea that'd be cool beans
w
Yeah - most examples I've seen (both from customers we've worked with and from samples we've built) actually create a resource group that all the resources in the Pulumi stack will be deployed into. Not required, but tends to be that Pulumi Stack and Azure Resource Group are logically close to 1:1.
s
I’ve actually never seen a canonical reference as to the “correct” way to use resource groups
And have seen various different sub-divisions in the wild
c
Yeah I can see that for certain scenarios but there are a lot of cases where that is not going to be good in production
for example in a large app I generally want persistent storage things in a different resource group than more ephemeral things
s
i'd like to see a proper example of how to work with multiple stacks too - at the moment i manually created resources i dont want to accidentally break (keyvaults etc) and then import them from one RG and use one single pulumi stack for the rest of things
w
Agreed - and to @stocky-spoon-28903's point there are a lot of different patterns and granularities of RG usage in the wild so this association is very approximate. Pulumi can support any mapping between these that makes sense for an application architecture.
s
but i'm wondering if i could have an 'infrastructure' stack and import its resources easily
w
@sparse-insurance-40223 You can do that, and I've worked with several customers who do exactly that once they have different "layers" that version at different rates. Today it requires exporting the things that are needed up-stack and then passing them in as Pulumi config inputs. We expect to add support for directly referencing outputs from another stack instead of going through the config system to get tighter integration betweem stacks. We're tracking that in https://github.com/pulumi/pulumi/issues/109, though our thinking on it has evolved a bit and I expect we'll make some improvements here in the near term.
👍 1
👍🏻 2
s
cool yea i'll subscribe to that issue
b
im going through something similar right now, what I've done is create a shared Utils utility for various stacks that read a yaml of the things im going to create, and in what region, and then I have 2 stacks, usually prod/dev. So, i have a project "core-rg" that will create the various resource groups by a known name like "Storage-Prod-WestUs-Rg", "KeyVault-Stage-EastUs2-Rg" and then when I create the vaults/storage accounts later I can know what RG they should go in based on their context - so I don't need to pass around the RG names. hope that helps