Search code examples
terraformterraform-provider-gcp

Get a signed URL of google storage object via Terraform


I am trying to get an object (ex. abc.png) signed URL from google bucket via a Terraform .tf script. But I am not getting any output on the console.

I have installed terraform on my local Linux machine, I am providing service account JSON key as credentials but not getting the signed URL, please check my script below:

provider "google" {
  credentials = "account.json"
}

data "google_storage_object_signed_url" "get_url" {
  bucket       = "my bucket"
  path         = "new.json"
  content_md5  = "pRviqwS4c4OTJRTe03FD1w=="
  content_type = "text/plain"
  duration     = "2h"
  credentials  = "account.json"

  extension_headers = {
    x-goog-if-generation-match = 1
  }
}

Please let me know what I am doing wrong.


Solution

  • If you need see Output Values, please add the Outputs code as below

    output "signed_url" {
      value = "${data.google_storage_object_signed_url.get_url.signed_url}"
    }