-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge UDMIF into faucetsdn UDMI (#296)
- Loading branch information
1 parent
06569cf
commit 0632590
Showing
189 changed files
with
50,402 additions
and
8 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
resource "google_storage_bucket" "function-bucket" { | ||
name = "${var.gcp_project_name}-${var.function_name}" | ||
project = var.gcp_project_id | ||
force_destroy = true | ||
storage_class = "STANDARD" | ||
location = "US" | ||
versioning { | ||
enabled = true | ||
} | ||
} | ||
|
||
data "archive_file" "source" { | ||
type = "zip" | ||
source_dir = "./src" | ||
output_path = "./function.zip" | ||
} | ||
# Add the zipped file to the bucket. | ||
resource "google_storage_bucket_object" "function-object" { | ||
# We can avoid unnecessary redeployments by validating the code is unchanged, and forcing | ||
# a redeployment when it has! | ||
name = "index.zip" | ||
bucket = google_storage_bucket.function-bucket.name | ||
source = data.archive_file.source.output_path | ||
lifecycle { | ||
ignore_changes = [detect_md5hash] | ||
} | ||
} | ||
# The cloud function resource. | ||
resource "google_cloudfunctions_function" "enventHandlerFunction" { | ||
available_memory_mb = var.function_memory | ||
entry_point = var.function_entry_point | ||
ingress_settings = "ALLOW_ALL" | ||
|
||
name = var.function_name | ||
project = var.gcp_project_id | ||
region = var.gcp_region | ||
runtime = var.function_runtime | ||
event_trigger { | ||
event_type = "providers/cloud.pubsub/eventTypes/topic.publish" | ||
resource = "udmi_target" | ||
} | ||
environment_variables = var.function_environment_variables | ||
source_archive_bucket = google_storage_bucket.function-bucket.name | ||
source_archive_object = google_storage_bucket_object.function-object.name | ||
} | ||
|
||
|
||
# IAM Configuration. This allows to provied access to the function. | ||
resource "google_cloudfunctions_function_iam_member" "invoker" { | ||
project = google_cloudfunctions_function.enventHandlerFunction.project | ||
region = google_cloudfunctions_function.enventHandlerFunction.region | ||
cloud_function = google_cloudfunctions_function.enventHandlerFunction.name | ||
|
||
role = "roles/cloudfunctions.invoker" | ||
member = var.gcp_access_group | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#GKE CLUSTER | ||
resource "google_container_cluster" "udmi" { | ||
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. | ||
|
||
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 | ||
} | ||
|
||
# Separately Managed Node Pool | ||
resource "google_container_node_pool" "node_pool" { | ||
name = var.gke_node_pool_name | ||
location = var.gke_cluster_location | ||
cluster = google_container_cluster.udmi.name | ||
node_count = var.gke_num_nodes | ||
|
||
node_config { | ||
|
||
# preemptible = true | ||
machine_type = var.gke_machine_type | ||
metadata = { | ||
disable-legacy-endpoints = "true" | ||
} | ||
} | ||
} | ||
|
||
resource "google_compute_global_address" "udmi_global_address"{ | ||
name = "udmi-global-address" | ||
project = var.gcp_project_id | ||
} | ||
|
||
resource "google_dns_managed_zone" "udmi_dns_zone" { | ||
name = var.gcp_project_name | ||
dns_name = var.dns_name | ||
project = var.gcp_project_id | ||
} | ||
|
||
resource "google_dns_record_set" "dns_record" { | ||
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}"] | ||
} | ||
|
||
resource "google_compute_managed_ssl_certificate" "udmi_ssl_certs" { | ||
name = "udmi-ssl" | ||
project = var.gcp_project_id | ||
managed { | ||
domains = var.ssl_domains | ||
} | ||
} | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
resource "mongodbatlas_project" "udmi" { | ||
name = var.project_name | ||
org_id = var.atlas_org_id | ||
} | ||
## mongodbatlas cluster | ||
resource "mongodbatlas_cluster" "udmi" { | ||
project_id = mongodbatlas_project.udmi.id | ||
name = var.cluster_name | ||
mongo_db_major_version = var.mongodb_version | ||
cluster_type = "REPLICASET" | ||
replication_specs { | ||
num_shards = 1 | ||
regions_config { | ||
region_name = var.cluster_region | ||
electable_nodes = 3 | ||
priority = 7 | ||
read_only_nodes = 0 | ||
} | ||
} | ||
# Provider Settings "block" | ||
provider_name = var.provider_name | ||
disk_size_gb = var.disk_size_gb | ||
provider_instance_size_name = var.instance_size_name | ||
auto_scaling_disk_gb_enabled = true | ||
provider_auto_scaling_compute_max_instance_size = var.auto_scaling_max_instance_size | ||
provider_auto_scaling_compute_min_instance_size = var.auto_scaling_min_instance_size | ||
} | ||
|
||
# DATABASE USER | ||
resource "mongodbatlas_database_user" "user" { | ||
username = var.db_username | ||
password = var.db_password | ||
project_id = mongodbatlas_project.udmi.id | ||
auth_database_name = "admin" | ||
|
||
roles { | ||
role_name = var.db_role | ||
database_name = var.database_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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# VPC | ||
resource "google_compute_network" "vpc" { | ||
count = var.create_vpc ? 1 : 0 | ||
name = "${var.gcp_vpc_name}-vpc" | ||
auto_create_subnetworks = "false" | ||
} | ||
|
||
# Subnet | ||
resource "google_compute_subnetwork" "subnet" { | ||
count = var.create_vpc ? 1 : 0 | ||
name = "${var.gcp_vpc_name}-subnet" | ||
region = var.gcp_region | ||
network = google_compute_network.vpc[count.index].name | ||
ip_cidr_range = var.ip_cidr_range | ||
} |
Empty file.
Oops, something went wrong.