https://pulumi.com logo
c

clever-guitar-55697

10/30/2018, 7:00 PM
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

stocky-spoon-28903

10/30/2018, 7:01 PM
It tends to be on a per resource basis
(Similar to the Terraform provider)
c

clever-guitar-55697

10/30/2018, 7:01 PM
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

stocky-spoon-28903

10/30/2018, 7:02 PM
Yes, that’s the case right now
c

clever-guitar-55697

10/30/2018, 7:02 PM
ok thanks
s

sparse-insurance-40223

10/30/2018, 7:02 PM
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

stocky-spoon-28903

10/30/2018, 7:03 PM
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

sparse-insurance-40223

10/30/2018, 7:03 PM
then when you do e.g. new keyvault you can specify the rg.name as the resourceGroupName
s

stocky-spoon-28903

10/30/2018, 7:03 PM
At some point we should go through and allow an
azure.core.ResourceGroup
as an alternative type for each of these
c

clever-guitar-55697

10/30/2018, 7:03 PM
ok thanks for the help
s

sparse-insurance-40223

10/30/2018, 7:03 PM
yea that'd be cool beans
w

white-balloon-205

10/30/2018, 7:04 PM
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

stocky-spoon-28903

10/30/2018, 7:04 PM
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

clever-guitar-55697

10/30/2018, 7:04 PM
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

sparse-insurance-40223

10/30/2018, 7:05 PM
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

white-balloon-205

10/30/2018, 7:06 PM
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

sparse-insurance-40223

10/30/2018, 7:06 PM
but i'm wondering if i could have an 'infrastructure' stack and import its resources easily
w

white-balloon-205

10/30/2018, 7:08 PM
@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

sparse-insurance-40223

10/30/2018, 7:11 PM
cool yea i'll subscribe to that issue
b

brave-angle-33257

10/31/2018, 2:35 AM
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