Search code examples
restterraformgoogle-cloud-pubsubsnapshotterraform-provider-gcp

What are approaches to calling gcp APIs from terraform? For ex, creating GCP pubsub Snapshot


I want to create snapshot, which is currently not available through GCP Terraform provider. So I want to be able to use the snapshot API call to achieve this. Once the snapshot is created, I need to call some external APIs as well, for instance call the remote server endpoint to restart the service.

What are the standard / better approaches with Terraform to do this? I am newbie with terraform. So no idea how to approach this.


Solution

  • You don't want to start using null_resources or calling scripts from Terraform if you can at all help it. You'd only want to use a local-exec/remote-exec where you really can't architect a proper solution.

    One alternative is to wrap this up in a Cloud Function and apply a cron trigger to it if the snapshotting is predictable.

    Alternatively you could also wrap it all up in a Workflow.