This was tested on a GCP Cloud Function using Python runtime 3.9. Make sure to also update the requirements.txt
(attached) as part of your Cloud Function
- There are several
print()
statements in the attached Python code for debugging purposes. These can be removed. - The Slack URL should be fed in via environment variable or secret since the URL contains secrets. From the Slack docs "Keep it secret, keep it safe. Your webhook URL contains a secret. Don't share it online, including via public version control repositories. Slack actively searches out and revokes leaked secrets."
- Here are the docs concerning Slack Block-Kit blocks for formatting the message
- In the GCP console, navigate to Pub/Sub and select "Topic" on the left-hand menu