https://pulumi.com logo
Title
m

millions-furniture-75402

03/19/2021, 8:02 PM
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:
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

red-match-15116

03/19/2021, 8:04 PM
Can you escape the
$
?
m

millions-furniture-75402

03/19/2021, 8:05 PM
same error
f

faint-table-42725

03/19/2021, 9:26 PM
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

millions-furniture-75402

03/22/2021, 1:54 PM
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

faint-table-42725

03/22/2021, 11:16 PM
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

millions-furniture-75402

03/23/2021, 1:01 PM
That is an interesting thought. We do have other custom ComponentResources if the need arises.