Hi, quick question. I'm dabbling with my first "D...
# general
a
Hi, quick question. I'm dabbling with my first "Dynamic Resource" via nodejs/typescript. All is working well with the exception of using the "import" command for resources already present downstream. Is that meant to work? or am i going mad?
This is what i'm getting atm:
Copy code
pulumi import -v 3 "pulumi-nodejs:dynamic:Resource" "foo" "53817d0f-<SNIP>"
Previewing import (vml)

View in Browser (Ctrl+O): <https://app.pulumi.com/darrensmithwtc/newrelic-manager/vml/previews/97763aee-81e8-42ad-ae03-85e46de9aab6>

     Type                               Name                  Plan       Info
     pulumi:pulumi:Stack                newrelic-manager-vml             1 error; 11 messages
 =   └─ pulumi-nodejs:dynamic:Resource  foo                   import     1 error

Diagnostics:
  pulumi:pulumi:Stack (newrelic-manager-vml):
    Error: code must be a string, not undefined: Error: code must be a string, not undefined
        at requireFromString (/home/dasmith/git/odeck-new/node_modules/require-from-string/index.js:19:9)
        at getProvider (/home/dasmith/git/odeck-new/node_modules/@pulumi/pulumi/cmd/dynamic-provider/index.js:70:20)
        at Object.<anonymous> (/home/dasmith/git/odeck-new/node_modules/@pulumi/pulumi/cmd/dynamic-provider/index.js:231:30)
        at Generator.next (<anonymous>)
        at /home/dasmith/git/odeck-new/node_modules/@pulumi/pulumi/cmd/dynamic-provider/index.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/home/dasmith/git/odeck-new/node_modules/@pulumi/pulumi/cmd/dynamic-provider/index.js:17:12)
        at Object.readRPC [as read] (/home/dasmith/git/odeck-new/node_modules/@pulumi/pulumi/cmd/dynamic-provider/index.js:225:12)
        at handleUnary (/home/dasmith/git/odeck-new/node_modules/@grpc/grpc-js/build/src/server.js:852:17)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

    error: preview failed

  pulumi-nodejs:dynamic:Resource (foo):
    error: Preview failed: code must be a string, not undefined
Gah finally found the "open issue" from 2021. https://github.com/pulumi/pulumi/issues/7534 - Shout out to @gifted-island-55702 for raising it and the workaround.
g
I had the same problem few weeks ago. The easiest ways for me was to implement create function/method in a way that reads existing resource and returns object with id and outs. Then
pulumi up
did the rest. What matters is to get those dynamic resources in a state.
a
yep 🙂 working on that now. Thanks for replying too. Appreciate it.