I'm trying to import a nested resource resource bu...
# general
r
I'm trying to import a nested resource resource but am having some trouble. I have this `import.json`:
Copy code
{
  "nameTable": {
    "internal-smoketest-master": "urn:pulumi:internal-smoketest::byoc::components:iac:aws:QuestDBCluster$components:iac:aws:Instance::internal-smoketest-master"
  },
  "resources": [
    {
      "id": "eni-attach-0636431dce761a217",
      "type": "aws:ec2/networkInterfaceAttachment:NetworkInterfaceAttachment",
      "name": "internal-smoketest-master-nic-attch",
      "parent": "internal-smoketest-master"
    }
  ]
}
but I'm getting weird error when I try to import the resource:
Copy code
➜  bleh git:(fix-aws-nic-attachments) ✗ pulumi import -f import.json --preview-only --protect=false
Previewing import (internal-smoketest):
     Type                 Name                     Plan     
     pulumi:pulumi:Stack  byoc-internal-smoketest           

Resources:
    47 unchanged

error: anonymous.pp:12,10-35: undefined variable internal-smoketest-master;
Am I doing this right? It's taken me a bit of time to figure out the import file format and nametable structure. For context, the nic attachment is a child of a component resource, "Instance", which itself is a component resource of "QuestDBCluster"
b
@rough-ice-18151 Typically it's better to use the
--import-file
option of
pulumi up
to let Pulumi create the import file. This saves you from figuring out the correct parents and their URNs.
r
Ah neat! Didn't know about that, thanks!
I don't see that documented anywhere though 😞 Can you point to a place where this is described in more detail?
b
@rough-ice-18151 Of course. And I'm stupid 😄 it's
pulumi preview
NOT
pulumi up
sorry if that created any confusion on your side. https://www.pulumi.com/docs/iac/adopting-pulumi/import/ https://www.pulumi.com/docs/iac/cli/commands/pulumi_preview/
r
ah that makes more sense, thanks!
🎉 1
🚀 1
♥️ 1