This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table zones.locations_geo | |
as | |
( | |
select name, value, ST_GeogPoint(lng, lat) point | |
from `akis-geoproject.zones.locations` | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table zones.locations_geo | |
as | |
( | |
select name, hours_at_target as value, ST_GeogPoint(lng, lat) point | |
from `akis-geoproject.zones.locations` | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table zones.zip_geo | |
as | |
( | |
select zcta5ce10 as zip, ST_GeogFromText(WKT) polygon | |
from `akis-geoproject.zones.zcta5` | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "google_compute_network" "vpc" { | |
name = "${format("%s","${var.company}-${var.env}-vpc")}" | |
auto_create_subnetworks = "false" | |
routing_mode = "GLOBAL" | |
} | |
resource "google_compute_firewall" "allow-internal" { | |
name = "${var.company}-fw-allow-internal" | |
network = "${google_compute_network.vpc.name}" | |
allow { | |
protocol = "icmp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "project" { | |
default = "gcp-project-id" | |
} | |
variable "region1" { | |
default = "us-west2" | |
} | |
variable "region2" { | |
default = "us-central1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "google" { | |
project = "${var.project}" | |
credentials = "${file("your_service_acct.json")}" | |
} | |
provider "google-beta" { | |
project = "${var.project}" | |
credentials = "${file("your_service_acct.json")}" | |
} |