-2

I have created GCP Log Sinks using gcloud command and it works. I now want to move that code into a CloudBuild.Yaml file equivalent. Can someone please point me to the log sink cloud build yaml template please or if you can convert the below command to a cloudbuild.yaml file?

My gcloud command is below which works successfully from cloud shell:

gcloud logging sinks create test3-${_ENV} pubsub.googleapis.com/projects/amer-xxxxxx-us-yyyy-dv/topics/pppp-topic-qqq-pubsub-dv --log-filter='(resource.labels.job_name=("amer-xxx-dv-df-xhxh-sel-details") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)")) OR (resource.labels.job_name=("amer-xxxx-dv-df-pqpq-sel-review") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)")) OR (resource.labels.job_name=("amer-xxxx-dv-df-pqpq-order") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)"))'
  

  • SO is not a free coding service and no one will be happy doing your work for free. Please try something a comeback with any specific questions of your attempts. Please check https://cloud.google.com/build/docs/build-config-file-schema yo know yo build the `YAML` – Puteri Apr 01 '22 at 16:50

1 Answers1

2

What's the difficulty?

- name: 'gcr.io/cloud-builders/gcloud'
  entrypoint: 'bash'
  args:
    - -c
    - |
        gcloud logging sinks create test3-${_ENV} pubsub.googleapis.com/projects/amer-xxxxxx-us-yyyy-dv/topics/pppp-topic-qqq-pubsub-dv --log-filter='(resource.labels.job_name=("amer-xxx-dv-df-xhxh-sel-details") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)")) OR (resource.labels.job_name=("amer-xxxx-dv-df-pqpq-sel-review") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)")) OR (resource.labels.job_name=("amer-xxxx-dv-df-pqpq-order") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)"))'
  

And set correctly your _ENV substitution variable when you invoke your Cloud Build

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76