Hi all, I have created a component resource that r...
# python
w
Hi all, I have created a component resource that represents aws vpc's (including subnets, route tables, associations, peering connections, etc) and wish to import some existing resources, I am really struggling to understand the docs around import here tho. https://www.pulumi.com/docs/cli/commands/pulumi_import/ Anyone able to give me some advice here please?
Is it even possible to import existing infrastructure into pulumi when the code that should represent them is a ComponentResource ?
h
the CLI mentions an alternate flow where you have
pulumi preview
generate an import file with
--import-file
, you edit that with your resource IDs, and then you pass it to
pulumi import
and then you presumably do a
pulumi up
to make sure it's all synchronized?
pulumi import
help says: > You can use
pulumi preview
with the
--import-file
option to emit an import file for all resources that need creating from the preview. This will fill in all the name, type, parent and provider information for you and just require you to fill in resource IDs and any properties.
w
Thanks, must have missed that. Going to give it a try
This seems to work well, bit tedious to get the ID for all resources but it works and is what I need, thank you very much!
h
yeah, i discovered that on accident, it seems simpler than trying to do it in code
w
so much so.. that's the direction i had started to go so this is the best thing to happen today 😄
h
if it's a lot of resources and you know your aws cli/api, you might be able to script something?
w
yes, i have 8 vpc's so it might be worth scripting.. going to test it a bit first tho. Thanks!
h