Thread
#general
    q

    quick-wolf-8403

    2 months ago
    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

    flat-laptop-90489

    2 months ago
    Import is likely what you need
    q

    quick-wolf-8403

    2 months ago
    thanks, Andy. Now to figure out how to extract the resource's ID
    Unless the docs are saying to invent one when importing
    f

    flat-laptop-90489

    2 months ago
    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

    quick-wolf-8403

    2 months ago
    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

    flat-laptop-90489

    2 months ago
    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

    quick-wolf-8403

    2 months ago
    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.