Folks, I'm looking for a way to move an existing G...
# general
q
Folks, I'm looking for a way to move an existing GCP service into being managed by Pulumi without having to delete the service and let Pulumi (re) create it. The stack thinks it needs to create a new service for prod. When I tried it out with dev and stage, I deleted the old service and let Pulumi create it anew. But I'd rather not do that in prod. Is there a way to let Pulumi know something already exists and it should just take over managing and updating it?
I'm hoping there's something clever in here: https://www.pulumi.com/docs/intro/concepts/resources/options/ maybe import?
f
Import is likely what you need
q
thanks, Andy. Now to figure out how to extract the resource's ID
Unless the docs are saying to invent one when importing
f
If you want to get really fancy, you can actually write code to look up the resource and then import it if it exists
Pulumi providers usually Have functions to do the look up of existing resources
q
I was doing something like that to look up existing services and spin up short-lived versions for testing PRs. So I think I know what you mean.
Looks like I was just confused by the AWS example in the docs. Experimentation shows me they want something like
'locations/{region}/namespaces/{project}/services/{service-name}')
Just the usual "where is your service?"
f
Yeah, that looks about right. The provider docs for the resource usually have import examples, but the GCP ones are often odd, as you're probably familiar with
q
Bit painful to get all the inputs matching exactly, too. For example, the names don't match for the secrets I was mounting as volumes via Cloud Build. Still, glad to know what it would take.
👍 1