https://pulumi.com logo
Title
c

clever-painter-96148

01/14/2023, 10:30 AM
When creating a resources.json file for
pulumi import
, how should we handle resources that do not actually exist, like providers and components? Context: I reimplemented a legacy TF code base with Pulumi. Now I want to write a script that generates a
resources.json
import file based on the terraform state. According to https://www.pulumi.com/docs/guides/adopting/import/,
id
is mandatory, but when reading a Pulumi state file, components have no ID.
Where can I see an example of a
resources.json
file that import resources with components as parents?
Update, for those who face the same kind of migration: passing
opts=ResourceOptions(import_="cloud-provider-identifier")
makes it much easier!
a

ancient-policeman-24615

01/14/2023, 6:19 PM
At the moment, it’s not possible to import resources that don’t actually exist in the underlying provider.
import
is essentially a way to tell Pulumi: “grab the underlying state of a resource from a cloud provider”. I think you’ll need to add components and providers after you run the import.
c

clever-painter-96148

01/17/2023, 9:38 AM
@ancient-policeman-24615 Passing
opts=ResourceOptions(import_="cloud-provider-identifier")
did the trick. I am now able to import all legacy resources into my Pulumi state, with components. 🙂