Hmm. Is it not possible to import GCP buckets pro...
# general
Hmm. Is it not possible to import GCP buckets programmatically in TypeScript ? I'm having an issue where the import fails (
warning: inputs to import do not match the existing resource; importing this resource will fail
) because some of the attributes of the existing bucket aren't set, but I can't actually set them as the result of
. For example, one bucket may need to set
which is a
pulumi.Input<string> | undefined
but since
returns an object whose logging member is
pulumi.Output<BucketLogging | undefined>
there's no way for me to unwrap
pulumi.Output<string> | undefined
pulumi.Output<string | undefined>
which is incompatible. Am I missing something ?
You don't import by building the managed resource from the results of a get function of the same (unmanaged) resource. You write the code as if the resource was being created. There is no get, and using a get function to populate the initial values is not correct. This is true whether you are using the
opt, or the
pulumi import
So it's not possible to import GCP buckets programmatically in TypeScript, right ?
For example, if I want to import a bucket which has a different configuration in Dev, QA, Staging, and Production using typescript I would need to manually get the bucket configuration for each environment through some external means, and then within the stack interpret that and construct the import based on something that indicates which environment it is
It's absolutely possible. But not within a single program. You'd have to do it like
pulumi import
does: get the information in one pass (the call to
pulumi import
, which generates code and updates the state), then
pulumi up
(begin managing the resource in Pulumi).
If you get the resource and begin to manage it in one piece of code, it becomes really hard to distinguish between things like a drifted resource and an unmanaged resource. Plus, it's Pulumi job to own and manage a resource; if something else is co-owning that resource (at least at resource creation time), then you're breaking the Pulumi use-case / model, and making like hard for yourself.