I created a GCP Cloud Functions which is triggered by a PubSub topic.
import base64
def hello_pubsub(event, context):
pubsub_message = base64.b64decode(event['data']).decode('utf-8')
print(pubsub_message)
I publish messages using the below command which triggers the Cloud Functions.
gcloud pubsub topics publish test-topic --message="test" \
--attribute="origin=gcloud-sample,username=gcp"
Using this I can access only the "message" part of the topic. How can I access the "attribute" values from the PubSub message. I want to fetch the origin and username from the topic.