Hi All. Has anyone had any success importing pre-e...
# getting-started
r
Hi All. Has anyone had any success importing pre-existing active GCP resources into their Pulumi stack? I've tried various documented methods without success so far. E.G.
error: Preview failed: unrecognized resource type (Read): gcp:compute:Instance
Am probably missing something obvious. I've tried with stacks configured with
gcp-python
and
google-native-yaml
templates.
l
Hello @rich-agency-75207, for each resource type, you can find in the API docs how to import it into your state file. The Pulumi CLI will usually also tell you which code snippet you need to add to your program as well. For your compute instance, have a look here: https://www.pulumi.com/registry/packages/gcp/api-docs/compute/instance/#import
r
@limited-rainbow-51650 👍 - was missing something obvious. That also explains another error concerning a missing self-link. Thanks.
l
Here is a blog article which sketches the usual import mechanism: https://www.pulumi.com/blog/pulumi-import-generate-iac-for-existing-cloud-resources/ which was updated in a more recent Pulumi version: https://www.pulumi.com/blog/changes-to-import/
1