How do I `pulumi import` a custom resource? The u...
# typescript
m
How do I
pulumi import
a custom resource? The urn has a
$
in it, e.g.:
db$aws:rds/instance:Instance
pulumi import 'db$aws:rds/instance:Instance' production-db-instance-rds prod-mariadb
fails with:
Copy code
panic: fatal: A precondition has failed for urn

goroutine 190 [running]:
<http://github.com/pulumi/pulumi/sdk/v2/go/common/util/contract.failfast(...)|github.com/pulumi/pulumi/sdk/v2/go/common/util/contract.failfast(...)>
r
Can you escape the
$
?
m
same error
f
I would not expect
db$
to be in the type token — was that in our documentation somewhere?
If so, would love to get that fixed. But I would try without the
db$
and that should work
m
for reference, this database was created using the custom ComponentResource provided in this example: https://github.com/pulumi/examples/blob/master/aws-stackreference-architecture/database/src/database.ts#L76
For our Disaster Recovery Test, we took a snapshot of our RDS Instance, and copied it to a new region, then created a new RDS Instance in the AWS Web Console with the snapshot. Then we ran our base-infrastructure with everything except the RDS Instance which is a child of the DB ComponentResource. Then tried to import it.
We did find that we can use Pulumi to use a snapshot when creating an RDS Instance, so we’ll take that approach next. However, using this custom ComponentResource has left us feeling like we’ve painted ourselves into a corner a little bit when it comes to importing infrastructure for this particular use case of import which I understand is different than the usual case.
Passing
snapshotIdentifier
was the easier solution for us.
f
Thanks for explaining. I think generally speaking, we’ll want to make importing `ComponentResource`s more straightforward. One thing you could try (which is more complex than the
snapshotIdentifier
solution you used) would be to use transformations to inject the additional
import
option into the correct child resources so that the
ComponentResource
hydrates correctly
m
That is an interesting thought. We do have other custom ComponentResources if the need arises.