From 4eb9c846654f59f5b9ead705f87c5d8e4bdc206c Mon Sep 17 00:00:00 2001 From: abidknashtech Date: Mon, 13 Nov 2023 15:49:24 +0530 Subject: [PATCH] josn key auth support for inventory --- deployment/gcpresources/terraform/main.tf | 20 ++++++++++++++++++- .../terraform/my-sql-instance-variables.tf | 7 ++++++- inventory-service/gcp-deploy-service.yaml | 11 ++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/deployment/gcpresources/terraform/main.tf b/deployment/gcpresources/terraform/main.tf index 7826a17b..9b61ab21 100644 --- a/deployment/gcpresources/terraform/main.tf +++ b/deployment/gcpresources/terraform/main.tf @@ -82,6 +82,24 @@ resource "google_pubsub_topic" "Vehicle" { message_retention_duration = "604800s" } +resource "google_pubsub_subscription" "inventory_subscription" { + name = "inventory_subscription" + topic = google_pubsub_topic.Vehicle.name + + # 20 minutes + message_retention_duration = "1200s" + retain_acked_messages = true + + ack_deadline_seconds = 20 + expiration_policy { + ttl = "300000.5s" + } + retry_policy { + minimum_backoff = "10s" + } + enable_message_ordering = false +} + #-----------------------GKE Cluster for applications---------------------------- resource "google_container_cluster" "car-demo-gke" { name = "car-demo-gke" @@ -144,5 +162,5 @@ resource "google_secret_manager_secret" "car-demo-secret" { resource "google_secret_manager_secret_version" "car-demo-secret-1" { secret = google_secret_manager_secret.car-demo-secret.id - secret_data = "{\"mysql-db-username\": \"${var.user_name}\", \"mysql-db-userpassword\": \"${var.user_password}\"}" + secret_data = "{\"mysql-db-username\": \"${var.user_name}\", \"mysql-db-userpassword\": \"${var.user_password}\", \"gcp_json_key\": \"${var.gcp_json_key}\"}" } diff --git a/deployment/gcpresources/terraform/my-sql-instance-variables.tf b/deployment/gcpresources/terraform/my-sql-instance-variables.tf index 2afff598..0835dd0a 100644 --- a/deployment/gcpresources/terraform/my-sql-instance-variables.tf +++ b/deployment/gcpresources/terraform/my-sql-instance-variables.tf @@ -66,7 +66,12 @@ variable user_name { default = "dbadmin" } -variable user_password { +variable guser_password { description = "The password for the default user. If not set, a random one will be generated and available in the generated_user_password output variable." default = "JavaDBs#password2023" } + +variable gcp_json_key { + description = "GCP Json key" + default = "{}" +} diff --git a/inventory-service/gcp-deploy-service.yaml b/inventory-service/gcp-deploy-service.yaml index a8956615..a764f536 100644 --- a/inventory-service/gcp-deploy-service.yaml +++ b/inventory-service/gcp-deploy-service.yaml @@ -35,6 +35,12 @@ spec: name: secret-to-be-created key: mysql-db-userpassword optional: false + - name: GOOGLE_APPLICATION_CREDENTIALS + valueFrom: + secretKeyRef: + name: secret-to-be-created + key: gcp_json_key + optional: false envFrom: - configMapRef: name: inventory-configmap @@ -93,6 +99,11 @@ spec: key: car-demo-secret version: latest property: mysql-db-userpassword + - secretKey: "gcp_json_key" + remoteRef: + key: car-demo-secret + version: latest + property: gcp_json_key - secretKey: "MY_SQL_SECRETS" remoteRef: