diff --git a/.header.md b/.header.md index 3c8ea5f..88fcc8c 100644 --- a/.header.md +++ b/.header.md @@ -35,6 +35,53 @@ moved { This focuses on the resources that are "heavy" or store data. Note that the ALB cannot be moved like this because Dogfood uses the `aws_alb` resource and the module uses the `aws_lb` resource. The resources are aliases of eachother, but Terraform can't recognize that. +# Cache Engine: Redis vs Valkey + +This module supports both Redis and [Valkey](https://valkey.io/) as the ElastiCache engine. Valkey is an open-source, Redis-compatible in-memory data store. + +## Provider Requirements + +When using this module, ensure your AWS provider version is >= 5.73.0: + +```hcl +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.73.0" + } + } +} +``` + +## Using Valkey (Recommended for Cost Savings) + +To use Valkey instead of Redis, configure the `redis_config` variable: + +```hcl +redis_config = { + engine = "valkey" + engine_version = "7.2" + family = "valkey7" + instance_type = "cache.m5.large" + cluster_size = 3 +} +``` + +## Using Redis (Default) + +Redis remains the default engine for backwards compatibility: + +```hcl +redis_config = { + engine = "redis" # Default + engine_version = "7.1" + family = "redis7" + instance_type = "cache.m5.large" + cluster_size = 3 +} +``` + # How to improve this module If this module somehow doesn't fit your needs, feel free to contact us by opening a ticket, or contacting your contact at Fleet. Our goal is to make this module diff --git a/README.md b/README.md index 65f8578..15878a8 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,53 @@ moved { This focuses on the resources that are "heavy" or store data. Note that the ALB cannot be moved like this because Dogfood uses the `aws_alb` resource and the module uses the `aws_lb` resource. The resources are aliases of eachother, but Terraform can't recognize that. +# Cache Engine: Redis vs Valkey + +This module supports both Redis and [Valkey](https://valkey.io/) as the ElastiCache engine. Valkey is an open-source, Redis-compatible in-memory data store. + +## Provider Requirements + +When using this module, ensure your AWS provider version is >= 5.73.0: + +```hcl +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.73.0" + } + } +} +``` + +## Using Valkey (Recommended for Cost Savings) + +To use Valkey instead of Redis, configure the `redis_config` variable: + +```hcl +redis_config = { + engine = "valkey" + engine_version = "7.2" + family = "valkey7" + instance_type = "cache.m5.large" + cluster_size = 3 +} +``` + +## Using Redis (Default) + +Redis remains the default engine for backwards compatibility: + +```hcl +redis_config = { + engine = "redis" # Default + engine_version = "7.1" + family = "redis7" + instance_type = "cache.m5.large" + cluster_size = 3 +} +``` + # How to improve this module If this module somehow doesn't fit your needs, feel free to contact us by opening a ticket, or contacting your contact at Fleet. Our goal is to make this module @@ -78,7 +125,7 @@ No resources. | [fleet\_config](#input\_fleet\_config) | The configuration object for Fleet itself. Fields that default to null will have their respective resources created if not specified. |
object({
task_mem = optional(number, null)
task_cpu = optional(number, null)
mem = optional(number, 4096)
cpu = optional(number, 512)
pid_mode = optional(string, null)
image = optional(string, "fleetdm/fleet:v4.78.0")
family = optional(string, "fleet")
sidecars = optional(list(any), [])
depends_on = optional(list(any), [])
mount_points = optional(list(any), [])
volumes = optional(list(any), [])
extra_environment_variables = optional(map(string), {})
extra_iam_policies = optional(list(string), [])
extra_execution_iam_policies = optional(list(string), [])
extra_secrets = optional(map(string), {})
security_group_name = optional(string, "fleet")
iam_role_arn = optional(string, null)
repository_credentials = optional(string, "")
private_key_secret_name = optional(string, "fleet-server-private-key")
service = optional(object({
name = optional(string, "fleet")
}), {
name = "fleet"
})
database = optional(object({
password_secret_arn = string
user = string
database = string
address = string
rr_address = optional(string, null)
}), {
password_secret_arn = null
user = null
database = null
address = null
rr_address = null
})
redis = optional(object({
address = string
use_tls = optional(bool, true)
}), {
address = null
use_tls = true
})
awslogs = optional(object({
name = optional(string, null)
region = optional(string, null)
create = optional(bool, true)
prefix = optional(string, "fleet")
retention = optional(number, 5)
}), {
name = null
region = null
prefix = "fleet"
retention = 5
})
loadbalancer = optional(object({
arn = string
}), {
arn = null
})
extra_load_balancers = optional(list(any), [])
networking = optional(object({
subnets = optional(list(string), null)
security_groups = optional(list(string), null)
ingress_sources = optional(object({
cidr_blocks = optional(list(string), [])
ipv6_cidr_blocks = optional(list(string), [])
security_groups = optional(list(string), [])
prefix_list_ids = optional(list(string), [])
}), {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
})
}), {
subnets = null
security_groups = null
ingress_sources = {
cidr_blocks = []
ipv6_cidr_blocks = []
security_groups = []
prefix_list_ids = []
}
})
autoscaling = optional(object({
max_capacity = optional(number, 5)
min_capacity = optional(number, 1)
memory_tracking_target_value = optional(number, 80)
cpu_tracking_target_value = optional(number, 80)
}), {
max_capacity = 5
min_capacity = 1
memory_tracking_target_value = 80
cpu_tracking_target_value = 80
})
iam = optional(object({
role = optional(object({
name = optional(string, "fleet-role")
policy_name = optional(string, "fleet-iam-policy")
}), {
name = "fleet-role"
policy_name = "fleet-iam-policy"
})
execution = optional(object({
name = optional(string, "fleet-execution-role")
policy_name = optional(string, "fleet-execution-role")
}), {
name = "fleet-execution-role"
policy_name = "fleet-iam-policy-execution"
})
}), {
name = "fleetdm-execution-role"
})
software_installers = optional(object({
create_bucket = optional(bool, true)
bucket_name = optional(string, null)
bucket_prefix = optional(string, "fleet-software-installers-")
s3_object_prefix = optional(string, "")
enable_bucket_versioning = optional(bool, false)
expire_noncurrent_versions = optional(bool, true)
noncurrent_version_expiration_days = optional(number, 30)
create_kms_key = optional(bool, false)
kms_alias = optional(string, "fleet-software-installers")
tags = optional(map(string), {})
}), {
create_bucket = true
bucket_name = null
bucket_prefix = "fleet-software-installers-"
s3_object_prefix = ""
enable_bucket_versioning = false
expire_noncurrent_versions = true
noncurrent_version_expiration_days = 30
create_kms_key = false
kms_alias = "fleet-software-installers"
tags = {}
})
})
|
{
"autoscaling": {
"cpu_tracking_target_value": 80,
"max_capacity": 5,
"memory_tracking_target_value": 80,
"min_capacity": 1
},
"awslogs": {
"create": true,
"name": null,
"prefix": "fleet",
"region": null,
"retention": 5
},
"cpu": 256,
"database": {
"address": null,
"database": null,
"password_secret_arn": null,
"rr_address": null,
"user": null
},
"depends_on": [],
"extra_environment_variables": {},
"extra_execution_iam_policies": [],
"extra_iam_policies": [],
"extra_load_balancers": [],
"extra_secrets": {},
"family": "fleet",
"iam": {
"execution": {
"name": "fleet-execution-role",
"policy_name": "fleet-iam-policy-execution"
},
"role": {
"name": "fleet-role",
"policy_name": "fleet-iam-policy"
}
},
"iam_role_arn": null,
"image": "fleetdm/fleet:v4.78.0",
"loadbalancer": {
"arn": null
},
"mem": 512,
"mount_points": [],
"networking": {
"ingress_sources": {
"cidr_blocks": [],
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"security_groups": []
},
"security_groups": null,
"subnets": null
},
"pid_mode": null,
"private_key_secret_name": "fleet-server-private-key",
"redis": {
"address": null,
"use_tls": true
},
"repository_credentials": "",
"security_group_name": "fleet",
"security_groups": null,
"service": {
"name": "fleet"
},
"sidecars": [],
"software_installers": {
"bucket_name": null,
"bucket_prefix": "fleet-software-installers-",
"create_bucket": true,
"s3_object_prefix": ""
},
"task_cpu": null,
"task_mem": null,
"volumes": []
}
| no | | [migration\_config](#input\_migration\_config) | The configuration object for Fleet's migration task. |
object({
mem = number
cpu = number
})
|
{
"cpu": 1024,
"mem": 2048
}
| no | | [rds\_config](#input\_rds\_config) | The config for the terraform-aws-modules/rds-aurora/aws module |
object({
name = optional(string, "fleet")
engine_version = optional(string, "8.0.mysql_aurora.3.08.2")
instance_class = optional(string, "db.t4g.large")
subnets = optional(list(string), [])
allowed_security_groups = optional(list(string), [])
allowed_cidr_blocks = optional(list(string), [])
apply_immediately = optional(bool, true)
monitoring_interval = optional(number, 10)
db_parameter_group_name = optional(string)
db_parameters = optional(map(string), {})
db_cluster_parameter_group_name = optional(string)
db_cluster_parameters = optional(map(string), {})
enabled_cloudwatch_logs_exports = optional(list(string), [])
master_username = optional(string, "fleet")
snapshot_identifier = optional(string)
cluster_tags = optional(map(string), {})
skip_final_snapshot = optional(bool, true)
backup_retention_period = optional(number, 7)
replicas = optional(number, 2)
serverless = optional(bool, false)
serverless_min_capacity = optional(number, 2)
serverless_max_capacity = optional(number, 10)
restore_to_point_in_time = optional(map(string), {})
})
|
{
"allowed_cidr_blocks": [],
"allowed_security_groups": [],
"apply_immediately": true,
"backup_retention_period": 7,
"cluster_tags": {},
"db_cluster_parameter_group_name": null,
"db_cluster_parameters": {},
"db_parameter_group_name": null,
"db_parameters": {},
"enabled_cloudwatch_logs_exports": [],
"engine_version": "8.0.mysql_aurora.3.08.2",
"instance_class": "db.t4g.large",
"master_username": "fleet",
"monitoring_interval": 10,
"name": "fleet",
"replicas": 2,
"restore_to_point_in_time": {},
"serverless": false,
"serverless_max_capacity": 10,
"serverless_min_capacity": 2,
"skip_final_snapshot": true,
"snapshot_identifier": null,
"subnets": []
}
| no | -| [redis\_config](#input\_redis\_config) | n/a |
object({
name = optional(string, "fleet")
replication_group_id = optional(string)
elasticache_subnet_group_name = optional(string)
allowed_security_group_ids = optional(list(string), [])
subnets = optional(list(string))
availability_zones = optional(list(string))
cluster_size = optional(number, 3)
instance_type = optional(string, "cache.m5.large")
apply_immediately = optional(bool, true)
automatic_failover_enabled = optional(bool, false)
engine_version = optional(string, "6.x")
family = optional(string, "redis6.x")
at_rest_encryption_enabled = optional(bool, true)
transit_encryption_enabled = optional(bool, true)
parameter = optional(list(object({
name = string
value = string
})), [])
log_delivery_configuration = optional(list(map(any)), [])
tags = optional(map(string), {})
})
|
{
"allowed_security_group_ids": [],
"apply_immediately": true,
"at_rest_encryption_enabled": true,
"automatic_failover_enabled": false,
"availability_zones": null,
"cluster_size": 3,
"elasticache_subnet_group_name": null,
"engine_version": "6.x",
"family": "redis6.x",
"instance_type": "cache.m5.large",
"log_delivery_configuration": [],
"name": "fleet",
"parameter": [],
"replication_group_id": null,
"subnets": null,
"tags": {},
"transit_encryption_enabled": true
}
| no | +| [redis\_config](#input\_redis\_config) | n/a |
object({
name = optional(string, "fleet")
replication_group_id = optional(string)
elasticache_subnet_group_name = optional(string)
allowed_security_group_ids = optional(list(string), [])
subnets = optional(list(string))
availability_zones = optional(list(string))
cluster_size = optional(number, 3)
instance_type = optional(string, "cache.m5.large")
apply_immediately = optional(bool, true)
automatic_failover_enabled = optional(bool, false)
engine = optional(string, "redis")
engine_version = optional(string, "7.1")
family = optional(string, "redis7")
at_rest_encryption_enabled = optional(bool, true)
transit_encryption_enabled = optional(bool, true)
parameter = optional(list(object({
name = string
value = string
})), [])
log_delivery_configuration = optional(list(map(any)), [])
tags = optional(map(string), {})
})
|
{
"allowed_security_group_ids": [],
"apply_immediately": true,
"at_rest_encryption_enabled": true,
"automatic_failover_enabled": false,
"availability_zones": null,
"cluster_size": 3,
"elasticache_subnet_group_name": null,
"engine": "redis",
"engine_version": "7.1",
"family": "redis7",
"instance_type": "cache.m5.large",
"log_delivery_configuration": [],
"name": "fleet",
"parameter": [],
"replication_group_id": null,
"subnets": null,
"tags": {},
"transit_encryption_enabled": true
}
| no | | [vpc](#input\_vpc) | n/a |
object({
name = optional(string, "fleet")
cidr = optional(string, "10.10.0.0/16")
azs = optional(list(string), ["us-east-2a", "us-east-2b", "us-east-2c"])
private_subnets = optional(list(string), ["10.10.1.0/24", "10.10.2.0/24", "10.10.3.0/24"])
public_subnets = optional(list(string), ["10.10.11.0/24", "10.10.12.0/24", "10.10.13.0/24"])
database_subnets = optional(list(string), ["10.10.21.0/24", "10.10.22.0/24", "10.10.23.0/24"])
elasticache_subnets = optional(list(string), ["10.10.31.0/24", "10.10.32.0/24", "10.10.33.0/24"])

create_database_subnet_group = optional(bool, false)
create_database_subnet_route_table = optional(bool, true)
create_elasticache_subnet_group = optional(bool, true)
create_elasticache_subnet_route_table = optional(bool, true)
enable_vpn_gateway = optional(bool, false)
one_nat_gateway_per_az = optional(bool, false)
single_nat_gateway = optional(bool, true)
enable_nat_gateway = optional(bool, true)
enable_dns_hostnames = optional(bool, false)
enable_dns_support = optional(bool, true)
enable_flow_log = optional(bool, false)
create_flow_log_cloudwatch_log_group = optional(bool, false)
create_flow_log_cloudwatch_iam_role = optional(bool, false)
flow_log_max_aggregation_interval = optional(number, 600)
flow_log_cloudwatch_log_group_name_prefix = optional(string, "/aws/vpc-flow-log/")
flow_log_cloudwatch_log_group_name_suffix = optional(string, "")
vpc_flow_log_tags = optional(map(string), {})
})
|
{
"azs": [
"us-east-2a",
"us-east-2b",
"us-east-2c"
],
"cidr": "10.10.0.0/16",
"create_database_subnet_group": false,
"create_database_subnet_route_table": true,
"create_elasticache_subnet_group": true,
"create_elasticache_subnet_route_table": true,
"create_flow_log_cloudwatch_iam_role": false,
"create_flow_log_cloudwatch_log_group": false,
"database_subnets": [
"10.10.21.0/24",
"10.10.22.0/24",
"10.10.23.0/24"
],
"elasticache_subnets": [
"10.10.31.0/24",
"10.10.32.0/24",
"10.10.33.0/24"
],
"enable_dns_hostnames": false,
"enable_dns_support": true,
"enable_flow_log": false,
"enable_nat_gateway": true,
"enable_vpn_gateway": false,
"flow_log_cloudwatch_log_group_name_prefix": "/aws/vpc-flow-log/",
"flow_log_cloudwatch_log_group_name_suffix": "",
"flow_log_max_aggregation_interval": 600,
"name": "fleet",
"one_nat_gateway_per_az": false,
"private_subnets": [
"10.10.1.0/24",
"10.10.2.0/24",
"10.10.3.0/24"
],
"public_subnets": [
"10.10.11.0/24",
"10.10.12.0/24",
"10.10.13.0/24"
],
"single_nat_gateway": true,
"vpc_flow_log_tags": {}
}
| no | ## Outputs diff --git a/byo-vpc/main.tf b/byo-vpc/main.tf index 46e55cb..c3e8b9b 100644 --- a/byo-vpc/main.tf +++ b/byo-vpc/main.tf @@ -89,20 +89,21 @@ module "rds" { module "redis" { source = "cloudposse/elasticache-redis/aws" - version = "0.53.0" + version = ">= 1.9.1" name = var.redis_config.name replication_group_id = var.redis_config.replication_group_id == null ? var.redis_config.name : var.redis_config.replication_group_id elasticache_subnet_group_name = var.redis_config.elasticache_subnet_group_name == null ? var.redis_config.name : var.redis_config.elasticache_subnet_group_name availability_zones = var.redis_config.availability_zones vpc_id = var.vpc_config.vpc_id - description = "Fleet Redis" + description = "Fleet cache" #allowed_security_group_ids = concat(var.redis_config.allowed_security_group_ids, module.byo-db.ecs.security_group) subnets = var.redis_config.subnets cluster_size = var.redis_config.cluster_size instance_type = var.redis_config.instance_type apply_immediately = var.redis_config.apply_immediately automatic_failover_enabled = var.redis_config.automatic_failover_enabled + engine = var.redis_config.engine engine_version = var.redis_config.engine_version family = var.redis_config.family at_rest_encryption_enabled = var.redis_config.at_rest_encryption_enabled diff --git a/byo-vpc/variables.tf b/byo-vpc/variables.tf index 84939f4..2b15023 100644 --- a/byo-vpc/variables.tf +++ b/byo-vpc/variables.tf @@ -77,8 +77,9 @@ variable "redis_config" { instance_type = optional(string, "cache.m5.large") apply_immediately = optional(bool, true) automatic_failover_enabled = optional(bool, false) - engine_version = optional(string, "6.x") - family = optional(string, "redis6.x") + engine = optional(string, "redis") + engine_version = optional(string, "7.1") + family = optional(string, "redis7") at_rest_encryption_enabled = optional(bool, true) transit_encryption_enabled = optional(bool, true) parameter = optional(list(object({ @@ -100,6 +101,7 @@ variable "redis_config" { instance_type = "cache.m5.large" apply_immediately = true automatic_failover_enabled = false + engine = "redis" engine_version = "6.x" family = "redis6.x" at_rest_encryption_enabled = true diff --git a/byo-vpc/versions.tf b/byo-vpc/versions.tf new file mode 100644 index 0000000..4a2fa17 --- /dev/null +++ b/byo-vpc/versions.tf @@ -0,0 +1,11 @@ +terraform { + required_version = ">= 1.3.8" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.73.0" + } + } +} + diff --git a/variables.tf b/variables.tf index cb1bef6..da5559a 100644 --- a/variables.tf +++ b/variables.tf @@ -126,8 +126,9 @@ variable "redis_config" { instance_type = optional(string, "cache.m5.large") apply_immediately = optional(bool, true) automatic_failover_enabled = optional(bool, false) - engine_version = optional(string, "6.x") - family = optional(string, "redis6.x") + engine = optional(string, "redis") + engine_version = optional(string, "7.1") + family = optional(string, "redis7") at_rest_encryption_enabled = optional(bool, true) transit_encryption_enabled = optional(bool, true) parameter = optional(list(object({ @@ -148,6 +149,7 @@ variable "redis_config" { instance_type = "cache.m5.large" apply_immediately = true automatic_failover_enabled = false + engine = "redis" engine_version = "6.x" family = "redis6.x" at_rest_encryption_enabled = true