Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Aki Atoji akiatoji

🏠
Working from home
  • TARDIS
Block or report user

Report or block akiatoji

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gunicorn_dockerfile.sh
ENV APP_HOME /app ENV PORT 8080 CMD exec gunicorn --bind 0.0.0.0:$PORT \
--workers 1 --chdir $APP_HOME --threads 1 app:app
View encrypting_secrets.sh
#!/usr/bin/env bash
gcloud services enable cloudkms.googleapis.com
KEYRING=keyring
KEY=secrets
gcloud kms keys list --location global --keyring $KEYRING
if [[ $? -ne 0 ]]; then
gcloud kms keyrings create ${KEYRING} --location global
View load_flask_secrets_from_bucket.py
import os
import uuid
from google.cloud import storage, kms_v1
def load(app):
config_file_name = "secrets-%s.cfg" % str(uuid.uuid4())
storage_client = storage.Client()
bucket = storage_client.get_bucket('vault')
View encrypted_flask_config.py
def load_from_encrypted(app):
tempname = str(uuid.uuid4())
encrypted_file_name = "secrets-%s.cfg.encrypted" % tempname
decrypted_file_name = "secrets-%s.cfg.decrypted" % tempname
storage_client = storage.Client()
bucket = storage_client.get_bucket('vault')
blob = bucket.blob('secrets.cfg.encrypted')
blob.download_to_filename(encrypted_file_name)
View overlay_flask_config.py
from my_lib import secrets
app = Flask(__name__)
# Load default config
app.config.from_pyfile('config/default_settings.py')
# Overlay secure secrets
secrets.load(app)
View create_geo_from_lat_lon.sql
create table zones.locations_geo
as
(
select name, value, ST_GeogPoint(lng, lat) point
from `akis-geoproject.zones.locations`
)
View create_geo_from_lat_lon.sql
create table zones.locations_geo
as
(
select name, hours_at_target as value, ST_GeogPoint(lng, lat) point
from `akis-geoproject.zones.locations`
)
View create_geo_from_wkt.sql
create table zones.zip_geo
as
(
select zcta5ce10 as zip, ST_GeogFromText(WKT) polygon
from `akis-geoproject.zones.zcta5`
)
View r1_instances.tf
resource "google_compute_instance" "web_ssh_r1" {
name = "${format("%s","${var.company}-${var.env}-${var.region1}-instance1")}"
machine_type = "n1-standard-1"
#zone = "${element(var.var_zones, count.index)}"
zone = "${format("%s","${var.region1}-b")}"
tags = [
"ssh",
"http"]
boot_disk {
initialize_params {
View r1_network.tf
resource "google_compute_subnetwork" "public_subnet_r1" {
name = "${format("%s","${var.company}-${var.env}-${var.region1}-pub-net")}"
ip_cidr_range = "${var.r1_public_subnet}"
network = "${google_compute_network.vpc.name}"
region = "${var.region1}"
}
resource "google_compute_subnetwork" "private_subnet_r1" {
name = "${format("%s","${var.company}-${var.env}-${var.region1}-pri-net")}"
ip_cidr_range = "${var.r1_private_subnet}"
network = "${google_compute_network.vpc.name}"
You can’t perform that action at this time.