Skip to content

Commit 041a014

Browse files
committed
adding tls support
1 parent bd79d3e commit 041a014

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

.idea/modules.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

autoscaler/redis-cloud-autoscaler/src/main/java/com/redis/autoscaler/RedisConfig.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.context.annotation.Bean;
55
import org.springframework.context.annotation.Configuration;
66
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
7+
import org.springframework.data.redis.connection.jedis.JedisClientConfiguration;
78
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
89
import org.springframework.data.redis.core.RedisTemplate;
910

@@ -18,18 +19,22 @@ public JedisConnectionFactory jedisConnectionFactory() {
1819
int redisPort = Integer.parseInt(redisHostAndPort.split(":")[1]);
1920
String redisPassword = System.getenv("REDIS_PASSWORD");
2021
String redisUser = System.getenv("REDIS_USER") != null ? System.getenv("REDIS_USER") : "default";
22+
boolean useSsl = System.getenv("REDIS_USE_SSL") != null && System.getenv("REDIS_USE_SSL").equalsIgnoreCase("true");
2123
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(redisHost, redisPort);
2224
LOG.info("connecting to redis at {}:{}", redisHost, redisPort);
23-
2425
if(redisPassword != null && !redisPassword.isEmpty()) {
2526
config.setPassword(redisPassword);
2627
}
2728

2829
if (redisUser != null && !redisUser.isEmpty()) {
2930
config.setUsername(redisUser);
3031
}
31-
32-
return new JedisConnectionFactory(config);
32+
JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfigurationBuilder = JedisClientConfiguration.builder();
33+
if(useSsl) {
34+
LOG.info("Using SSL to connect to Redis");
35+
jedisClientConfigurationBuilder.useSsl();
36+
}
37+
return new JedisConnectionFactory(config, jedisClientConfigurationBuilder.build());
3338
}
3439

3540
@Bean

main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ resource "google_compute_firewall" "autoscale_allow_egress" {
8585

8686

8787
data "rediscloud_payment_method" "card"{
88-
card_type = "Visa"
88+
card_type = "Mastercard"
8989
last_four_numbers = var.last_four_digits
9090
}
9191

@@ -135,6 +135,7 @@ resource "rediscloud_subscription_database" "autoscale-database" {
135135
throughput_measurement_by = "operations-per-second"
136136
throughput_measurement_value = 1000
137137
memory_limit_in_gb = 0.5
138+
enable_tls = true
138139
modules = [
139140
{
140141
"name" : "RedisJSON"
@@ -183,7 +184,7 @@ resource "null_resource" "build_app" {
183184
}
184185

185186
provisioner "file" {
186-
source = "./autoscaler/redis-cloud-autoscaler/build/libs/redis-cloud-autoscaler-0.0.4.jar"
187+
source = "./autoscaler/redis-cloud-autoscaler/build/libs/redis-cloud-autoscaler-0.0.5.jar"
187188
destination = "autoscaler.jar"
188189
}
189190

@@ -213,6 +214,7 @@ resource "null_resource" "build_app" {
213214
"echo 'Environment=REDIS_CLOUD_API_KEY=${var.redis_cloud_api_key}' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null",
214215
"echo 'Environment=REDIS_CLOUD_ACCOUNT_KEY=${var.redis_cloud_account_key}' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null",
215216
"echo 'Environment=REDIS_CLOUD_SUBSCRIPTION_ID=${rediscloud_subscription.autoscaling_sub.id}' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null",
217+
"echo 'Environment=REDIS_USE_SSL=true' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null",
216218
"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",
217219
"echo 'Environment=ALERT_MANAGER_PORT=9093' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null",
218220
"echo 'ExecStart=/usr/bin/java -jar /usr/local/bin/autoscaler.jar' | sudo tee -a /etc/systemd/system/autoscaler.service > /dev/null",

quickstart/gcp/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ resource "google_compute_firewall" "autoscale_allow_egress" {
8484

8585

8686
data "rediscloud_payment_method" "card"{
87-
card_type = "Visa"
87+
card_type = "Mastercard"
8888
last_four_numbers = var.last_four_digits
8989
}
9090

@@ -108,7 +108,7 @@ resource "rediscloud_subscription" "autoscaling_sub" {
108108

109109
creation_plan {
110110
memory_limit_in_gb = 5
111-
quantity = 3
111+
quantity = 1
112112
replication = false
113113
throughput_measurement_by = "operations-per-second"
114114
throughput_measurement_value = 25000

0 commit comments

Comments
 (0)