Skip to content

GoogleCloudStorage target

Sends events to GoogleCloudStorage.

With tmctl:

tmctl create target googlecloudstorage --bucketName <bucketName> --credentialsJson $(cat ./creds.json)

On Kubernetes:

Secret

apiVersion: v1
kind: Secret
metadata:
  name: googlecloudstorage
type: Opaque
stringData:
  creds: |-
    {
      "type": "service_account",
      "project_id": "dev",
      "private_key_id": "e1e4ad14a8d234adf4963d398863ad12444df",
      "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQQWFNBgkqhkiG9w0BAQEFAASCB...R6Y=\n-----END PRIVATE KEY-----\n",
      "client_email": "tst-27@dev.iam.gserviceaccount.com",
      "client_id": "11547922342598721477",
      "auth_uri": "https://accounts.google.com/o/oauth2/auth",
      "token_uri": "https://oauth2.googleapis.com/token",
      "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
      "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gstst-27%40dev.iam.gserviceaccount.com"
    }

Target

apiVersion: targets.triggermesh.io/v1alpha1
kind: GoogleCloudStorageTarget
metadata:
  name: googlecloudstorage
spec:
  bucketName: tmdemo
  credentialsJson:
    secretKeyRef:
      name: googlecloudstorage
      key: creds

The target accepts events of type com.google.cloud.storage.object.insert to pass payload with the following properties:

  • data: []byte, base64 encoded data
  • fileName: string, the file name with type (ex. 'file.png')

You can test the Target by sending it an event using curl:

curl -v "localhost:8080" \
       -X POST \
       -H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f79" \
       -H "Ce-Specversion: 1.0" \
       -H "Ce-Type: com.google.cloud.storage.object.insert" \
       -H "Ce-Source: dev.knative.samples/helloworldsource" \
       -H "Content-Type: application/json" \
       -d '{"data":"iVBORw0KGgoAAAANSUhEUgAAAIUAAABYCAYAAADbejTNAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAAQTSURBVHhe7ZtRjuQ4DEP3Tn3/s/VAH1oQEi3LsVM1yfABBDoiLQdV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j6KkXA8yMhbOZUHrKyYycbnyPoqxSAZ9mZ7sypPGRlx042PkfQ/6dLEb2VrLGaZ6zs2MnG5wj6Hy2FMfLZ3Gfd+YjuDpYzWNYY5Y3KQzwXs2zOZsbOzIjzr5VipAjLoDqwcy6E+VEImzmVF/HsSA7zUEg1G8n5eCkcfJlZnmXx5w54vjpb5WbPSOUxPI/n8GeDeThDRnMDz7HM8VKI+xh9iadRKR6ESiESKoVIqBTiS/z+/gGzfSWEBhuJawAAAABJRU5ErkJggg==","fileName":"img4.png"}'

See the Kubernetes object reference for more details.

Prerequisites

  • Google Storage enabled in Google Cloud Console
  • A Google Cloud Service account with rights to the storage resources and the credentials in JSON format.