Hey, should I be able to run `pulumi refresh` with...
# general
f
Hey, should I be able to run
pulumi refresh
with empty state and existing resources, and get that state synced up? I have an old stack where the state was stored locally in files that I haven't touched in a while. Now when I run
pulumi up
it connects to the cloud, sees no resources, and tries to create them all. But these resources exist and were previously created by Pulumi, so my thinking was that
pulumi refresh
should slurp them in. It doesn't, though, and always shows an empty modifications list. And
pulumi up
keeps offering to recreate everything. How do I import these resources into the cloud so I can keep managing them with Pulumi? Please tell me I don't have to import nearly 40 resources individually. 🙂
q
I'm afraid, you'll need to import those resources. You don't have to import them one-by-one though. You can run
pulumi preview
with the
--import-file
option to create an import file. That way you only have to fill in the IDs and can import all of them at once with
pulumi import --file ...
.
f
Thanks, I have the import file. What sorts of values should I use for the placeholder in the ID?
q
That depends on the resource/provider you're using. Commonly it's the primary identifier of the resource, but it can very from resource to resource. Usually the docs of the resources have a
Import
section explaining that: https://www.pulumi.com/registry/packages/aws/api-docs/alb/loadbalancer/#import
f
Hmm, not so for hcloud, am I missing it somewhere else? https://www.pulumi.com/registry/packages/hcloud/ Thanks a bunch.
q
The import IDs are generally different per resource. You can find them in the docs of the resource you're looking at. For example: https://www.pulumi.com/registry/packages/hcloud/api-docs/server/#import