Skip to content

Instantly share code, notes, and snippets.

View ivamluz's full-sized avatar

Ivam Luz ivamluz

  • Appnovation
  • Campinas
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ivamluz on github.
  • I am ivamluz (https://keybase.io/ivamluz) on keybase.
  • I have a public key ASAF4-9VJHfurF23oGUjRbdCuPFYVwbIgZ5QkdPj0N0UtAo

To claim this, I am signing this object:

@ivamluz
ivamluz / test-deployed-pubsub-output
Created July 28, 2020 00:30
test-deployed-pubsub.sh command output
> ./test-deployed-pubsub.sh "Hello, Pub/Sub!" "foo=bar,bar=baz,attr=value"
Publishing 'Hello, Pub/Sub!' message with foo=bar,bar=baz,attr=value attributes to builder-functions-demo-topic
messageIds:
- '1399123306686402'
@ivamluz
ivamluz / test-deployed-http-output
Last active July 28, 2020 00:24
test-deployed-http.sh command output
> ./test-deployed-http.sh
Sending GET request to https://<region>-<project-id>.cloudfunctions.net/sample_http?subject=FooBar
HTTP/2 200
content-type: text/html; charset=utf-8
function-execution-id: nm07fwaspcwl
x-cloud-trace-context: b607a137968b883068619c9bed376b4d;o=1
date: Tue, 28 Jul 2020 00:19:48 GMT
server: Google Frontend
content-length: 14
@ivamluz
ivamluz / main.py
Created July 28, 2020 00:07
HTTP- and Pub/Sub-triggered functions
import base64
import pprint as pp
from flask import current_app, escape
def sample_http(request):
"""HTTP Cloud Function.
Args:
request (flask.Request): The request object.
<http://flask.pocoo.org/docs/1.0/api/#flask.Request>
@ivamluz
ivamluz / test-deployed-pubsub.sh
Created July 27, 2020 23:56
Script for testing the Pub/Sub-triggered deployed function
#! /bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${DIR}/.env.local"
MESSAGE=$1
ATTRIBUTES=$2
gcloud pubsub topics \
@ivamluz
ivamluz / test-deployed-http.sh
Last active July 28, 2020 00:27
Script for testing the HTTP-triggered deployed function
#! /bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_DIR="${DIR}/../src"
source "${DIR}/.env.local"
TRIGGER_URL=$(
gcloud functions \
describe ${FUNCTION_NAME_HTTP} \
@ivamluz
ivamluz / deploy-pubsub.sh
Created July 19, 2020 21:04
Scripting for deploying the Pub/Sub-triggered cloud function
#! /bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_DIR="${DIR}/../src"
source "${DIR}/.env.local"
gcloud functions \
deploy ${FUNCTION_NAME_PUBSUB} \
--source=${SOURCE_DIR} \
@ivamluz
ivamluz / deploy-http.sh
Created July 19, 2020 21:03
Scripting for deploying the HTTP-triggered cloud function
#! /bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_DIR="${DIR}/../src"
source "${DIR}/.env.local"
gcloud functions \
deploy ${FUNCTION_NAME_HTTP} \
--source=${SOURCE_DIR} \
@ivamluz
ivamluz / cloudbuild.yaml
Last active July 28, 2020 00:09
Cloud Build configuration for deploying Cloud Functions on GCP
steps:
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
args: ["./scripts/deploy-http.sh"]
waitFor: ["-"]
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
args: ["./scripts/deploy-pubsub.sh"]
waitFor: ["-"]
Script path: venv/bin/functions-framework
Parameters: --source=src/main.py --target=${FUNCTION_NAME_HTTP} --signature-type=http --port=${FUNCTION_PORT_HTTP} --debug
Environment variables: PYTHONUNBUFFERED=1
Working directory: /home/iluz/Projects/Personal/cloud-build-cloud-functions-pipeline/