Skip to content

Instantly share code, notes, and snippets.

View itsMagondu's full-sized avatar
🎯
Focusing

Samuel Magondu Njenga itsMagondu

🎯
Focusing
View GitHub Profile
@itsMagondu
itsMagondu / main.tf
Created August 20, 2019 11:02
Main terraform file to control modules
# variables
variable project {}
variable region {}
variable zone {}
variable billing_id {}
variable org_id {}
variable k8s_username {}
variable k8s_password {}
variable metabase_db_user {}
variable metabase_db_password {}
@itsMagondu
itsMagondu / main.tf
Created August 20, 2019 11:02
Main terraform file to control modules
# variables
variable project {}
variable region {}
variable zone {}
variable billing_id {}
variable org_id {}
variable k8s_username {}
variable k8s_password {}
variable metabase_db_user {}
variable metabase_db_password {}
@itsMagondu
itsMagondu / gcp-project.tf
Created August 20, 2019 10:58
Create a GCP project using terraform
provider "google" {
project = "${var.project}"
zone = "${var.zone}"
}
resource "google_project" "demo_project" {
name = "${var.project}"
project_id = "${var.project}-id"
org_id = "${var.org_id}"
billing_account = "${var.billing_id}"
@itsMagondu
itsMagondu / gcp-outputs.tf
Created August 20, 2019 10:57
Terraform outputs for GCP project
output "project_id" {
value = "${google_project.demo_project.project_id}"
}
output "cloudsql_proxy_sa_key" {
value = "${google_service_account_key.cloudsql_proxy_sa_key.private_key}"
}
@itsMagondu
itsMagondu / cloudsql-instance.tf
Created August 20, 2019 10:55
Setup CloudSQL db using terraform
resource "google_sql_database_instance" "demo_instance" {
project = "${var.project_id}"
name = "demo-db"
region = "${var.region}"
database_version = "POSTGRES_9_6"
settings {
tier = "db-f1-micro"
disk_autoresize = true
@itsMagondu
itsMagondu / cloudsql-variables.tf
Created August 20, 2019 10:54
Terraform input variables for CloudSQL
variable project_id {}
variable region {}
variable metabase_db_user {}
variable metabase_db_password {}
@itsMagondu
itsMagondu / sql-outputs.tf
Created August 20, 2019 10:52
Terraform outputs for CloudSQL
output "metabase_db_name" {
value = "${google_sql_database.metabase_database.name}"
}
output "db_instance_connection_name" {
value = "${google_sql_database_instance.demo_instance.connection_name}"
}
variable project_id {}
variable cloudsql_proxy_sa_key {}
variable zone {}
variable k8s_username {}
variable k8s_password {}
variable db_instance_connection_name {}
variable metabase_db_name {}
variable metabase_db_user {}
variable metabase_db_password {}
@itsMagondu
itsMagondu / gke_cluster.tf
Last active August 20, 2019 10:14
Setup a Kubernetes cluster on GCP. Initialize the terraform kubernetes provider too.
resource "google_container_cluster" "primary" {
project = "${var.project_id}"
name = "demo-cluster"
location = "${var.zone}"
remove_default_node_pool = true
initial_node_count = 1
master_auth {
username = "${var.k8s_username}"
@itsMagondu
itsMagondu / metabase.tf
Last active October 1, 2020 21:29
A terraform script to setup metabase on GKE
resource "kubernetes_deployment" "metabase" {
metadata {
name = "metabase"
labels = {
app = "metabase"
}
namespace = "${kubernetes_namespace.sandbox.metadata.0.name}"
}
spec {
replicas = 1