Skip to content

Instantly share code, notes, and snippets.

@cleibl

cleibl/main.py Secret

Last active April 2, 2019 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleibl/f993cd4a9cd847ebca667154ab0381ca to your computer and use it in GitHub Desktop.
Save cleibl/f993cd4a9cd847ebca667154ab0381ca to your computer and use it in GitHub Desktop.
Parse PubSub
import base64
import json
import googleapiclient.discovery
import string
import time
def process_log_entry(data, context):
#base64 decode the data field
data_buffer = base64.b64decode(data['data'])
#Load JSON so we can parse it
log_entry = json.loads(data_buffer)
# Get Firewall Name by Parsing Log
firewall_name = log_entry['jsonPayload']['resource']['name']
# Get Project ID by Parsing Log
project_id = log_entry['resource']['labels']['project_id']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment