https://pulumi.com logo
Title
b

bitter-twilight-16606

04/24/2023, 5:40 PM
Question regarding existing resources. I've defined a resource group with the azure native provider in code and this resource group already exists in azure. I have an empty stack. If I do pulumi refresh it does not add the resource group. Do I have to import it? If so, how does this scale to many existing resources - I have to manually look up all the resource IDs and construct import commands for each one? Is there a better way to achieve this?
b

billowy-army-68599

04/24/2023, 5:41 PM
yes you have to import it, you can use an import file to automate this: https://www.pulumi.com/docs/reference/cli/pulumi_import/
b

bitter-twilight-16606

04/24/2023, 5:54 PM
Thanks. Any idea why there is no option to "refresh" from the code? Seems like unnecessary overhead to have to manually import when pulumi could do from the name defined in the code.
b

billowy-army-68599

04/24/2023, 5:55 PM
refresh reconciles the cloud provider API with pulumi state. If you haven’t imported the resource into state it can’t do any refresh
if you look in the state, Pulumi keeps track of a resource ID. it cannot know that cloud provider generated resource ID, you have to tell Pulumi about it
b

bitter-twilight-16606

04/24/2023, 5:59 PM
the resource ID is made up from the resource group and the name, which are both in the code
Is there an easy way to get a list of the resource IDs. Specifically I'm setting up code for azure k8s.