https://pulumi.com logo
#getting-started
Title
# getting-started
m

most-mouse-38002

06/13/2022, 12:12 PM
I want to use, but not manage (as in leave it alone if I bring down the stack), an existing resource group in Azure. Is
resources.LookupResourceGroup
the correct way to go about this? Seing as it returns a
resources.LookupResourceGroupResult
I am a bit confused; I can of course manually turn this into a
resources.ResourceGroup
but is that really “the way”?
e

echoing-dinner-19531

06/13/2022, 12:26 PM
You probably want to import the resource group and then use retain on delete to ensure you don't actually delete it when done with the stack.
m

most-mouse-38002

06/13/2022, 12:37 PM
So there is no equivalent to Terraforms
data
to just let Pulumi know that “this thing exists, but as read only”?
e

echoing-dinner-19531

06/13/2022, 12:38 PM
Oh if you just want read only use the resource
get
methods. https://www.pulumi.com/registry/packages/azure-native/api-docs/resources/getresourcegroup/
👍 1
m

most-mouse-38002

06/13/2022, 12:40 PM
Correct, I just want to read it, but I also want what I read to become a
ResourceGroup
and not
LookupResourceGroupResult
. Note that I am using Go.
e

echoing-dinner-19531

06/13/2022, 12:43 PM
OK I'm not sure why this isn't in docs but there is also a
GetResourceGroup
function (https://github.com/pulumi/pulumi-azure-native/blob/master/sdk/go/azure/resources/resourceGroup.go#L106) which does return a
ResourceGroup
object.
m

most-mouse-38002

06/13/2022, 12:48 PM
I must be missing something, but using this method requires both a name and a
pulumi.ID
which confuses me. an ID in Azure would be something along the lines of
Copy code
/subscriptions/$subscription_uuid/resourceGroups/foo
and
/foo
would also be the name of said resource group. I would assume
GetResourceGroup
could infer this information on its own, but having tested it does not and I need to copy that entire line into
pulumi.ID
?
e

echoing-dinner-19531

06/13/2022, 12:50 PM
So the name in that call is just a Pulumi logical name, same as the name you would pass for any
NewResource
calls to create a resource. As for the ID we don't try and do any smarts in the SDK to shorten IDs, we just take the literal that the cloud provider SDK expects.
Just to be clear the name given to this function does not need to match the name of the resource in azure
m

most-mouse-38002

06/13/2022, 12:51 PM
Right, gotcha. That clears it up at least, just want to make sure I do things correctly.
Thanks a lot 🙂
4 Views