I want to use, but not manage (as in leave it alon...
# getting-started
m
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
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
So there is no equivalent to Terraforms
data
to just let Pulumi know that “this thing exists, but as read only”?
e
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
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
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
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
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
Right, gotcha. That clears it up at least, just want to make sure I do things correctly.
Thanks a lot 🙂