Skip to content

Commit f0cfb76

Browse files
Added comparable deployments for EC 7.1 and Redis Cloud (#135)
* Added comparable deployments for EC 7.1 and Redis Cloud * Added password output --------- Co-authored-by: filipecosta90 <filipecosta.90@gmail.com>
1 parent a56547d commit f0cfb76

File tree

11 files changed

+225
-0
lines changed

11 files changed

+225
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
terraform {
3+
required_providers {
4+
rediscloud = {
5+
source = "RedisLabs/rediscloud"
6+
version = "1.0.3"
7+
}
8+
}
9+
}
10+
11+
# This is a data source, so it will run at plan time.
12+
data "external" "env" {
13+
program = ["${path.cwd}/env.sh"]
14+
15+
# For Windows (or Powershell core on MacOS and Linux),
16+
# run a Powershell script instead
17+
#program = ["${path.module}/env.ps1"]
18+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
data "rediscloud_payment_method" "card" {
3+
card_type = "Mastercard"
4+
last_four_numbers = data.external.env.result["rediscloud_payment_4digits"]
5+
}
6+
7+
8+
data "rediscloud_cloud_account" "account" {
9+
exclude_internal_account = true
10+
provider_type = "AWS"
11+
name = "PERFORMANCE"
12+
}
13+
14+
15+
resource "rediscloud_subscription" "subscription-resource" {
16+
17+
name = var.subscription_name
18+
payment_method = "credit-card"
19+
payment_method_id = data.rediscloud_payment_method.card.id
20+
memory_storage = "ram"
21+
22+
cloud_provider {
23+
cloud_account_id = data.rediscloud_cloud_account.account.id
24+
region {
25+
region = "us-east-2"
26+
networking_deployment_cidr = "10.3.22.0/24"
27+
networking_vpc_id = data.terraform_remote_state.shared_resources.outputs.performance_cto_vpc_id
28+
preferred_availability_zones = ["us-east-2a"]
29+
}
30+
}
31+
32+
// This block needs to be defined for provisioning a new subscription.
33+
// This allows creating a well-optimised hardware specification for databases in the cluster
34+
creation_plan {
35+
memory_limit_in_gb = var.memory_limit_in_gb
36+
quantity = 1
37+
replication = var.replication
38+
support_oss_cluster_api = var.support_oss_cluster_api
39+
throughput_measurement_by = "operations-per-second"
40+
throughput_measurement_value = var.ops_sec
41+
modules = []
42+
}
43+
44+
timeouts {
45+
create = "15m"
46+
update = "15m"
47+
delete = "15m"
48+
}
49+
}
50+
51+
52+
// The primary database to provision
53+
resource "rediscloud_subscription_database" "database-resource" {
54+
subscription_id = rediscloud_subscription.subscription-resource.id
55+
name = var.db_name
56+
protocol = "redis"
57+
memory_limit_in_gb = var.memory_limit_in_gb
58+
data_persistence = "none"
59+
password = ""
60+
throughput_measurement_by = "operations-per-second"
61+
throughput_measurement_value = var.ops_sec
62+
external_endpoint_for_oss_cluster_api = false
63+
replication = var.replication
64+
support_oss_cluster_api = var.support_oss_cluster_api
65+
depends_on = [rediscloud_subscription.subscription-resource]
66+
67+
timeouts {
68+
create = "15m"
69+
update = "15m"
70+
delete = "15m"
71+
}
72+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# env.sh
4+
5+
# Change the contents of this output to get the environment variables
6+
# of interest. The output must be valid JSON, with strings for both
7+
# keys and values.
8+
cat <<EOF
9+
{
10+
"rediscloud_payment_4digits": "$REDIS_CLOUD_PAYMENT_4DIGITS",
11+
"rediscloud_default_password": "$REDIS_CLOUD_DEFAULT_PASSWORD"
12+
}
13+
EOF
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
output "public_endpoint" {
3+
value = ["${rediscloud_subscription_database.database-resource.public_endpoint}"]
4+
}
5+
6+
output "private_endpoint" {
7+
value = ["${rediscloud_subscription_database.database-resource.private_endpoint}"]
8+
}
9+
10+
output "password" {
11+
value = ["${rediscloud_subscription_database.database-resource.password}"]
12+
sensitive = true
13+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# provider
2+
provider "aws" {
3+
region = var.region
4+
}
5+
6+
################################################################################
7+
# This is the shared resources bucket key -- you will need it across environments like security rules,etc...
8+
# !! do not change this !!
9+
################################################################################
10+
data "terraform_remote_state" "shared_resources" {
11+
backend = "s3"
12+
config = {
13+
bucket = "performance-cto-group"
14+
key = "benchmarks/infrastructure/shared_resources.tfstate"
15+
region = "us-east-1"
16+
}
17+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
################################################################################
2+
# Variables used for deployment tag
3+
################################################################################
4+
5+
variable "db_name" {
6+
description = "db name"
7+
default = "perf-14GB-20K-single-endpoint-db"
8+
}
9+
10+
variable "subscription_name" {
11+
description = "db name"
12+
default = "perf-14GB-20K-single-endpoint-db"
13+
}
14+
15+
16+
variable "ops_sec" {
17+
description = "db name"
18+
default = 20000
19+
}
20+
21+
variable "memory_limit_in_gb" {
22+
description = "memory_limit_in_gb"
23+
default = 14
24+
}
25+
26+
variable "replication" {
27+
description = "replication"
28+
default = false
29+
}
30+
31+
variable "support_oss_cluster_api" {
32+
description = "support_oss_cluster_api"
33+
default = false
34+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
################################################################################
3+
# This is the bucket holding this specific setup tfstate
4+
################################################################################
5+
terraform {
6+
backend "s3" {
7+
bucket = "performance-cto-group"
8+
region = "us-east-1"
9+
key = "ec-1-primaries-v7-m7g.large"
10+
}
11+
}
12+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
resource "aws_elasticache_replication_group" "ec" {
3+
automatic_failover_enabled = false
4+
preferred_cache_cluster_azs = ["us-east-2a"]
5+
replication_group_id = "ec-1-primaries-v7-m7g-large"
6+
description = "xlarge cache"
7+
node_type = "cache.m7g.large"
8+
num_cache_clusters = 1
9+
parameter_group_name = "default.redis7"
10+
engine = "redis"
11+
port = 6379
12+
security_group_ids = ["${data.terraform_remote_state.shared_resources.outputs.performance_cto_sg_id}"]
13+
subnet_group_name = "ec-subnet"
14+
at_rest_encryption_enabled = false
15+
data_tiering_enabled = false
16+
}
17+
18+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
output "ec_members" {
3+
value = ["${aws_elasticache_replication_group.ec}"]
4+
sensitive = true
5+
}
6+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# provider
2+
provider "aws" {
3+
region = var.region
4+
}
5+
6+
################################################################################
7+
# This is the shared resources bucket key -- you will need it across environments like security rules,etc...
8+
# !! do not change this !!
9+
################################################################################
10+
data "terraform_remote_state" "shared_resources" {
11+
backend = "s3"
12+
config = {
13+
bucket = "performance-cto-group"
14+
key = "benchmarks/infrastructure/shared_resources.tfstate"
15+
region = "us-east-1"
16+
}
17+
}

0 commit comments

Comments
 (0)