Skip to content

Commit

Permalink
Merge biot udmi to faucetsdn (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
slevertbiot committed Aug 3, 2022
1 parent 8007b0e commit 942cd29
Show file tree
Hide file tree
Showing 149 changed files with 16,039 additions and 7,372 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ check_links.out
dashboard/functions/node_modules/
dashboard/public/deploy_version.js
firebase-debug.log
credentials.json
/out/
/validator/build/
/validator/out/
Expand All @@ -29,6 +30,7 @@ __pycache__/

.vscode

#Terraform authentication and template files.
cloud/gcp/terraform.tfvars
cloud/gcp/udmi-sites.tf
cloud/gcp/main.tf
Expand Down
38 changes: 38 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
api:
stage: build
variables:
WORKING_DIR: udmif/api
trigger:
include: udmif/api/build.yml
rules:
- changes:
- "udmif/api/**/*"

web:
stage: build
variables:
WORKING_DIR: udmif/web
trigger:
include: udmif/web/build.yml
rules:
- changes:
- "udmif/web/**/*"

event-handler:
stage: build
variables:
WORKING_DIR: udmif/event-handler
trigger:
include: udmif/event-handler/build.yml
rules:
- changes:
- "udmif/event-handler/**/*"

gcp:
stage: build
trigger:
include: cloud/gcp/build.yml
rules:
- changes:
- "cloud/gcp/**/*"

30 changes: 19 additions & 11 deletions cloud/gcp/api.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
resource "google_project_service" "site_iam" {
project = var.gcp_project_id
service = "iam.googleapis.com"
}
resource "google_project_service" "service" {
for_each = toset([
"cloudresourcemanager.googleapis.com",
"serviceusage.googleapis.com",
"compute.googleapis.com",
"pubsub.googleapis.com",
"dns.googleapis.com",
"iam.googleapis.com",
"storage.googleapis.com",
"sourcerepo.googleapis.com",
"cloudiot.googleapis.com",
"cloudfunctions.googleapis.com",
"cloudbuild.googleapis.com",
"container.googleapis.com",
"containerregistry.googleapis.com"
])

resource "google_project_service" "site_storage" {
project = var.gcp_project_id
service = "storage.googleapis.com"
}
service = each.key

resource "google_project_service" "site_sourcerepo" {
project = var.gcp_project_id
service = "sourcerepo.googleapis.com"
project = var.gcp_project_id
disable_on_destroy = false
}
1 change: 1 addition & 0 deletions cloud/gcp/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include:
file: terraform/base.yml

stages:
- test
- init
- validate
- build
Expand Down
57 changes: 0 additions & 57 deletions cloud/gcp/functions.tf

This file was deleted.

40 changes: 19 additions & 21 deletions cloud/gcp/gks.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "google_service_account" "gke" {
account_id = "gkeuser"
display_name = "GKE Service Account"
project = var.gcp_project_id
project = var.gcp_project_id
}
resource "google_project_iam_member" "gke_gcr_binding" {
project = var.gcp_project_id
Expand All @@ -10,26 +10,24 @@ resource "google_project_iam_member" "gke_gcr_binding" {
}
#GKE CLUSTER
resource "google_container_cluster" "udmi" {
project = var.gcp_project_id
name = var.gke_cluster_name
location = var.gke_cluster_location
node_locations = var.gke_node_locations
project = var.gcp_project_id
name = var.gke_cluster_name
location = var.gke_cluster_location
node_locations = var.gke_node_locations

# We can't create a cluster with no node pool defined, but we want to only use
# separately managed node pools. So we create the smallest possible default
# node pool and immediately delete it.

remove_default_node_pool = true

initial_node_count = var.gke_initial_node_count

network = var.create_vpc ? google_compute_network.vpc[0].name : null
subnetwork = var.create_vpc ? google_compute_subnetwork.subnet[0].name : null
network = var.create_vpc ? google_compute_network.vpc[0].name : null
subnetwork = var.create_vpc ? google_compute_subnetwork.subnet[0].name : null
}

# Separately Managed Node Pool
resource "google_container_node_pool" "node_pool" {
project = var.gcp_project_id
project = var.gcp_project_id
name = var.gke_node_pool_name
location = var.gke_cluster_location
cluster = google_container_cluster.udmi.name
Expand All @@ -42,7 +40,7 @@ resource "google_container_node_pool" "node_pool" {

# Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles.
service_account = google_service_account.gke.email
oauth_scopes = [
oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring"
Expand All @@ -54,31 +52,31 @@ resource "google_container_node_pool" "node_pool" {
}

#This resource creates static IP
resource "google_compute_global_address" "udmi_global_address"{
name = "udmi-global-address"
project = var.gcp_project_id
resource "google_compute_global_address" "udmi_global_address" {
name = "udmi-global-address"
project = var.gcp_project_id
}

#This resource creates clouddns entry
resource "google_dns_managed_zone" "udmi_dns_zone" {
name = var.gcp_project_name
dns_name = var.dns_name
project = var.gcp_project_id
project = var.gcp_project_id
}

#This resource creates A record in cloud dns
resource "google_dns_record_set" "dns_record" {
project = var.gcp_project_id
project = var.gcp_project_id
managed_zone = var.gcp_project_name
name = "*.${var.dns_name}"
type = "A"
ttl = 300
rrdatas = ["${google_compute_global_address.udmi_global_address.address}"]
name = "*.${var.dns_name}"
type = "A"
ttl = 300
rrdatas = ["${google_compute_global_address.udmi_global_address.address}"]
}

#This resouce creates ssl certs
resource "google_compute_managed_ssl_certificate" "udmi_ssl_certs" {
name = "udmi-ssl"
name = "udmi-ssl"
project = var.gcp_project_id
managed {
domains = var.ssl_domains
Expand Down
2 changes: 1 addition & 1 deletion cloud/gcp/mongodb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ resource "mongodbatlas_database_user" "user" {

roles {
role_name = var.db_role
database_name = var.database_name
database_name = var.database_name
}
}
2 changes: 1 addition & 1 deletion cloud/gcp/storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ resource "google_storage_bucket" "tf-bucket" {
enabled = true
}
lifecycle {
# Stop any terraform plan which would destroy this GCP project.
# Stop any terraform plan which would destroy this bucket.
prevent_destroy = true
}
}
15 changes: 15 additions & 0 deletions cloud/gcp/terraform.tfvars.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#See the variable.tf file for a list of all the variables that can be configured and their default values.
#Variables can be overriden here as needed when a default is provided. They must be defined here when no default is provided.

# GCP Settings
gcp_project_id = "@GCP_PROJECT_ID@"
gcp_project_name = "@GCP_PROJECT_NAME@"
Expand All @@ -13,3 +16,15 @@ gcp_access_group = "group:@GCP_PROJECT_GROUP@"

# Log level
log_level = "DEBUG"

#cloud DNS variables and ssl domains for UDMIF. Use a domain you own.
dns_name = "udmi.mydomain.com."
ssl_domains = ["web.udmi.mydomain.com", "api.udmi.mydomain.com"]

#GKE an other related variables

#MongoDB Atlas
atlas_org_id = "YourAtlasOrgId"
public_key = "YourAtlasPublicKey"
private_key = "YourAtlasPrivateKey@"
db_password = "YourUdmiDbpassword"
Loading

0 comments on commit 942cd29

Please sign in to comment.