From 041a01478ea40a3ccb09f905b49e0210b24ad748 Mon Sep 17 00:00:00 2001 From: slorello89 Date: Wed, 17 Sep 2025 10:32:53 -0400 Subject: [PATCH 1/2] adding tls support --- .idea/modules.xml | 1 + .../main/java/com/redis/autoscaler/RedisConfig.java | 11 ++++++++--- main.tf | 6 ++++-- quickstart/gcp/main.tf | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 0da5d1e..8407c72 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,7 @@ + \ No newline at end of file diff --git a/autoscaler/redis-cloud-autoscaler/src/main/java/com/redis/autoscaler/RedisConfig.java b/autoscaler/redis-cloud-autoscaler/src/main/java/com/redis/autoscaler/RedisConfig.java index 644622a..ae90e75 100644 --- a/autoscaler/redis-cloud-autoscaler/src/main/java/com/redis/autoscaler/RedisConfig.java +++ b/autoscaler/redis-cloud-autoscaler/src/main/java/com/redis/autoscaler/RedisConfig.java @@ -4,6 +4,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisStandaloneConfiguration; +import org.springframework.data.redis.connection.jedis.JedisClientConfiguration; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; @@ -18,9 +19,9 @@ public JedisConnectionFactory jedisConnectionFactory() { int redisPort = Integer.parseInt(redisHostAndPort.split(":")[1]); String redisPassword = System.getenv("REDIS_PASSWORD"); String redisUser = System.getenv("REDIS_USER") != null ? System.getenv("REDIS_USER") : "default"; + boolean useSsl = System.getenv("REDIS_USE_SSL") != null && System.getenv("REDIS_USE_SSL").equalsIgnoreCase("true"); RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(redisHost, redisPort); LOG.info("connecting to redis at {}:{}", redisHost, redisPort); - if(redisPassword != null && !redisPassword.isEmpty()) { config.setPassword(redisPassword); } @@ -28,8 +29,12 @@ public JedisConnectionFactory jedisConnectionFactory() { if (redisUser != null && !redisUser.isEmpty()) { config.setUsername(redisUser); } - - return new JedisConnectionFactory(config); + JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfigurationBuilder = JedisClientConfiguration.builder(); + if(useSsl) { + LOG.info("Using SSL to connect to Redis"); + jedisClientConfigurationBuilder.useSsl(); + } + return new JedisConnectionFactory(config, jedisClientConfigurationBuilder.build()); } @Bean diff --git a/main.tf b/main.tf index 918dede..09f64a7 100644 --- a/main.tf +++ b/main.tf @@ -85,7 +85,7 @@ resource "google_compute_firewall" "autoscale_allow_egress" { data "rediscloud_payment_method" "card"{ - card_type = "Visa" + card_type = "Mastercard" last_four_numbers = var.last_four_digits } @@ -135,6 +135,7 @@ resource "rediscloud_subscription_database" "autoscale-database" { throughput_measurement_by = "operations-per-second" throughput_measurement_value = 1000 memory_limit_in_gb = 0.5 + enable_tls = true modules = [ { "name" : "RedisJSON" @@ -183,7 +184,7 @@ resource "null_resource" "build_app" { } provisioner "file" { - source = "./autoscaler/redis-cloud-autoscaler/build/libs/redis-cloud-autoscaler-0.0.4.jar" + source = "./autoscaler/redis-cloud-autoscaler/build/libs/redis-cloud-autoscaler-0.0.5.jar" destination = "autoscaler.jar" } @@ -213,6 +214,7 @@ resource "null_resource" "build_app" { "echo 'Environment=REDIS_CLOUD_API_KEY=${var.redis_cloud_api_key}' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null", "echo 'Environment=REDIS_CLOUD_ACCOUNT_KEY=${var.redis_cloud_account_key}' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null", "echo 'Environment=REDIS_CLOUD_SUBSCRIPTION_ID=${rediscloud_subscription.autoscaling_sub.id}' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null", + "echo 'Environment=REDIS_USE_SSL=true' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null", "echo 'Environment=ALERT_MANAGER_HOST=${google_compute_instance.autoscale-vm-prometheus.network_interface[0].access_config[0].nat_ip}' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null", "echo 'Environment=ALERT_MANAGER_PORT=9093' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null", "echo 'ExecStart=/usr/bin/java -jar /usr/local/bin/autoscaler.jar' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null", diff --git a/quickstart/gcp/main.tf b/quickstart/gcp/main.tf index 6f807d9..910824d 100644 --- a/quickstart/gcp/main.tf +++ b/quickstart/gcp/main.tf @@ -84,7 +84,7 @@ resource "google_compute_firewall" "autoscale_allow_egress" { data "rediscloud_payment_method" "card"{ - card_type = "Visa" + card_type = "Mastercard" last_four_numbers = var.last_four_digits } @@ -108,7 +108,7 @@ resource "rediscloud_subscription" "autoscaling_sub" { creation_plan { memory_limit_in_gb = 5 - quantity = 3 + quantity = 1 replication = false throughput_measurement_by = "operations-per-second" throughput_measurement_value = 25000 From cf5b202b4ce73e030382389b43c5a64efcb9eca7 Mon Sep 17 00:00:00 2001 From: slorello89 Date: Wed, 17 Sep 2025 10:34:02 -0400 Subject: [PATCH 2/2] docs --- README.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/README.adoc b/README.adoc index 1ef0b76..d89e12a 100644 --- a/README.adoc +++ b/README.adoc @@ -29,6 +29,7 @@ The Redis Cloud Autoscaler is and application designed to run in your own enviro | Name | Description | REDIS_HOST_AND_PORT | The private endpoint of the Redis Cloud subscription database. | REDIS_PASSWORD | The password for accessing the Redis Cloud database. +| REDIS_USE_SSL | Whether to use TLS when connecting to the Redis Cloud database (true/false). | REDIS_CLOUD_API_KEY | The API key for interacting with Redis Cloud services. | REDIS_CLOUD_ACCOUNT_KEY | The account key for authenticating with Redis Cloud. | REDIS_CLOUD_SUBSCRIPTION_ID | The ID of the Redis Cloud subscription.