Skip to content

Commit

Permalink
corrected postgres network (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkotibiot authored Mar 11, 2023
1 parent a53592b commit f532a58
Show file tree
Hide file tree
Showing 38 changed files with 1,528 additions and 502 deletions.
4 changes: 0 additions & 4 deletions cloud/gcp/main.tf.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ terraform {
source = "hashicorp/google"
version = "~> 3.0"
}
mongodbatlas = {
source = "mongodb/mongodbatlas"
version = "~> 1.3.1"
}
}
backend "gcs" {
bucket = "@GCP_PROJECT_ID@-terraform"
Expand Down
40 changes: 0 additions & 40 deletions cloud/gcp/mongodb.tf

This file was deleted.

17 changes: 9 additions & 8 deletions cloud/gcp/postgresql.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,23 @@ resource "google_sql_database_instance" "main" {
}
}

resource "google_compute_network" "private_network" {
name = "private-network"
resource "google_compute_network" "default" {
name = "default"
description = "Default network for the project"
}

resource "google_compute_global_address" "private_ip_address" {
name = "private-ip-address"
resource "google_compute_global_address" "default_ip_address" {
name = "default-ip-address"
purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 16
network = google_compute_network.private_network.id
network = google_compute_network.default.id
}

resource "google_service_networking_connection" "private_vpc_connection" {
network = google_compute_network.private_network.id
resource "google_service_networking_connection" "default_vpc_connection" {
network = google_compute_network.default.id
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.private_ip_address.name]
reserved_peering_ranges = [google_compute_global_address.default_ip_address.name]
}

resource "google_sql_database" "database" {
Expand Down
4 changes: 0 additions & 4 deletions cloud/gcp/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ provider "google" {
region = var.gcp_region
}

provider "mongodbatlas" {
public_key = var.public_key
private_key = var.private_key
}

15 changes: 10 additions & 5 deletions cloud/gcp/terraform.tfvars.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ 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"
## Postgresql variable
instance_name = "PostgreSQLInstaceName"
database_version = "PostgreSQLserverVersion"
region = "@GCP_PROJECT_REGION@"
tier = "TheMachineType"
environment = "InstanceEnvforLabel"
db_name = "DataBaseName"
db_user = "DataBaseUser"
password = "DataBasePassword"

77 changes: 0 additions & 77 deletions cloud/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -148,80 +148,3 @@ variable "password" {
description = "Postgresql db password in GCP"
}

## Mongodb variables
variable "public_key" {
type = string
description = "This is the public key of udmi MongoDB Atlas API key pair."
}
variable "private_key" {
type = string
description = "This is the private key of udmi MongoDB Atlas key pair."
}
variable "atlas_org_id" {
type = string
description = "The ID of the organization udmi want to create the project within."
}
variable "project_name" {
type = string
default = "udmi"
description = "The name of the project udmi wants to create"
}
variable "cluster_name" {
type = string
default = "udmi"
description = "Name of the cluster as it appears in Atlas. Once the cluster is created, its name cannot be changed."
}
variable "mongodb_version" {
type = string
default = "5.0"
description = "Version of the cluster to deploy."
}
variable "cluster_region" {
type = string
default = "CENTRAL_US"
description = "Physical location of your MongoDB cluster."
}
variable "provider_name" {
type = string
default = "GCP"
description = "Cloud service provider on which the servers are provisioned."
}
variable "disk_size_gb" {
type = string
default = "20"
description = "Maximum disk size for the mongo instance"
}
variable "instance_size_name" {
type = string
default = "M10"
description = "mongodb instance name"
}
variable "auto_scaling_min_instance_size" {
type = string
default = "M10"
description = "auto scalling min instance size when scaling down"
}
variable "auto_scaling_max_instance_size" {
type = string
default = "M20"
description = "auto scalling max instance size when scaling up"
}
variable "db_username" {
type = string
default = "udmi"
description = "Username for authenticating to MongoDB."
}
variable "db_password" {
type = string
description = "User's initial password. A value is required to create the database user"
}
variable "database_name" {
type = string
default = "udmi"
description = "Database on which the user has the specified role."
}
variable "db_role" {
type = string
default = "readWrite"
description = "Name of the role to grant to the database user."
}
2 changes: 1 addition & 1 deletion cloud/gcp/vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ resource "google_compute_subnetwork" "subnet" {
resource "google_vpc_access_connector" "connector" {
name = "udmi-cf-sql-vpc"
ip_cidr_range = "10.9.0.0/28"
network = "private-network"
network = "default"
max_throughput = 300
}
83 changes: 11 additions & 72 deletions udmif/api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion udmif/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dependencies": {
"apollo-datasource-graphql": "^1.3.2",
"apollo-server": "^3.6.2",
"dataloader": "^2.1.0",
"dotenv": "^16.0.0",
"google-auth-library": "^7.14.1",
"graphql": "^16.2.0",
Expand Down Expand Up @@ -44,4 +45,4 @@
"lint-staged": {
"{src,util}/**/*.{ts,tsx,json}": "prettier --single-quote --arrow-parens always --trailing-comma es5 --print-width 120 --write"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Oh yah, and there was a missing field too.",
"serialNumber": "serialNo-1",
"site": "LOC-1",
"state": "ERROR",
"uuid": "00000000-0000-0000-0000-000000000001",
"validation": "{\\"version\\":\\"1.3.14\\",\\"timestamp\\":\\"2018-08-26T21:39:29.364Z\\",\\"sub_type\\":\\"event\\",\\"sub_folder\\":\\"discovery\\",\\"status\\":{\\"message\\":\\"Failed schema validation\\",\\"detail\\":\\"The field x.y was unexpected on line 232 of the message.\\\\nThis is by following the logic train x.y.z in the overall flow of the sytem.\\\\nRabbits are really interesting creatures and make great pets.\\\\nOh yah, and there was a missing field too.\\",\\"category\\":\\"validation.device.result\\",\\"timestamp\\":\\"2018-08-26T21:39:30.364Z\\",\\"level\\":600},\\"pointset\\":{\\"missing\\":[\\"filter_differential_pressure_setpoint\\"]},\\"errors\\":[]}",
},
},
Expand Down
1 change: 1 addition & 0 deletions udmif/api/src/__tests__/device/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const QUERY_DEVICES = gql`
const QUERY_DEVICE = gql`
query {
device(id: "some-id") {
uuid
id
name
make
Expand Down
5 changes: 4 additions & 1 deletion udmif/api/src/__tests__/site/MockSiteDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export default class MockSiteDataSource extends GraphQLDataSource<object> {
}

async getSiteValidation(name: string): Promise<SiteValidation> {
return siteMessage;
if (name === 'site1' || name.startsWith('SITE-') || name.startsWith('LOC-')) {
return siteMessage;
}
return null;
}

async getSiteDeviceStatus(name: string, deviceName: string): Promise<Status> {
Expand Down
Loading

0 comments on commit f532a58

Please sign in to comment.