https://pulumi.com logo
Title
b

bland-florist-21412

06/01/2021, 8:18 PM
I was hoping to get some advice on how to use Pulumi to spin up Google Cloud Endpoints with OpenAPI auth (https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions#reserve_hostname). The hard part is that it's a few steps and involves replacing a resource. Specifically, step 1 is to run something via Google's cloud run. It doesn't matter what container is run at this point; all that matters is we're "reserving" a unique hostname for our eventual cloud run service. Then we use the uniquely assigned hostname to create a text file that defines the routing and auth, then we include that generated text file in a docker image, and finally we replace the initial cloud run service with this new container. Since Pulumi's model is generally describe what you want and Pulumi will "make it so" this doesn't map neatly as we have to create a cloud run service that is temporary and we don't want it running when we're all done. The best idea I've come up with so far is a custom, dynamic resource provider that will create the temporary cloud run service and then "lie" in its
diff
method and such so that if it's been replaced it says not changes need to happen. I got that mostly working but it seems you can't use
pulumi_gcp
to create the temporary service inside the custom provider (I get an error that says, "Program run without the Pulumi engine available; re-run using the
pulumi
CLI" even though it was run via
pulumi up
). Even if I could use
pulumi_gcp
I don't see a way to destroy the resource created in the
create
method when
delete
is called. So I can make this work with native API calls or Google's own Python SDK but that all seems like more work than should be necessary. Is there a clean way to do this?