Hmm. Is it not possible to import GCP buckets pro...
# general
d
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
gcp.storage.Bucket.get()
. For example, one bucket may need to set
logging.logObjectPrefix
which is a
pulumi.Input<string> | undefined
but since
gcp.storage.Bucket.get()
returns an object whose logging member is
pulumi.Output<BucketLogging | undefined>
there's no way for me to unwrap
logging.logObjectPrefix
into
pulumi.Output<string> | undefined
only
pulumi.Output<string | undefined>
which is incompatible. Am I missing something ?
l
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
import
opt, or the
pulumi import
tool.
d
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
l
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.