Skip to content

Instantly share code, notes, and snippets.

View akiatoji's full-sized avatar
🕋
Currently traveling in time.

Aki Atoji akiatoji

🕋
Currently traveling in time.
  • TARDIS
View GitHub Profile
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)
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)
create table zones.locations_geo
as
(
select name, value, ST_GeogPoint(lng, lat) point
from `akis-geoproject.zones.locations`
)
create table zones.locations_geo
as
(
select name, hours_at_target as value, ST_GeogPoint(lng, lat) point
from `akis-geoproject.zones.locations`
)
create table zones.zip_geo
as
(
select zcta5ce10 as zip, ST_GeogFromText(WKT) polygon
from `akis-geoproject.zones.zcta5`
)
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 {
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}"
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"
variable "project" {
default = "gcp-project-id"
}
variable "region1" {
default = "us-west2"
}
variable "region2" {
default = "us-central1"
provider "google" {
project = "${var.project}"
credentials = "${file("your_service_acct.json")}"
}
provider "google-beta" {
project = "${var.project}"
credentials = "${file("your_service_acct.json")}"
}