https://pulumi.com logo
#python
Title
# python
w

witty-battery-28013

03/14/2024, 3:25 PM
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

hundreds-gpu-71155

03/14/2024, 4:06 PM
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

witty-battery-28013

03/14/2024, 4:13 PM
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

hundreds-gpu-71155

03/14/2024, 4:21 PM
yeah, i discovered that on accident, it seems simpler than trying to do it in code
w

witty-battery-28013

03/14/2024, 4:22 PM
so much so.. that's the direction i had started to go so this is the best thing to happen today 😄
h

hundreds-gpu-71155

03/14/2024, 4:23 PM
if it's a lot of resources and you know your aws cli/api, you might be able to script something?
w

witty-battery-28013

03/14/2024, 4:25 PM
yes, i have 8 vpc's so it might be worth scripting.. going to test it a bit first tho. Thanks!
h

hundreds-gpu-71155

03/14/2024, 4:27 PM