Skip to content

Commit 298ee9d

Browse files
authored
[feature] Add CIDR blocks based security group to Redis (#286)
1 parent 488c4ea commit 298ee9d

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

aws-redis-node/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ parameters.
2525
| engine\_version | The version of Redis to run. See [supported versions](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/supported-engine-versions.html) | `string` | `"5.0.5"` | no |
2626
| env | Env for tagging and naming. See [doc](../README.md#consistent-tagging). | `string` | n/a | yes |
2727
| ingress\_security\_group\_ids | Source security groups which should be able to contact this instance. | `list(string)` | n/a | yes |
28+
| ingress\_security\_group\_cidr_blocks | CIDR blocks which should be able to contact this instance. | `list(string)` | [] | no |
2829
| instance\_type | The type of instance to run. See [supported node types](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheNodes.SupportedTypes.html) | `string` | `"cache.m5.large"` | no |
2930
| owner | Owner for tagging and naming. See [doc](../README.md#consistent-tagging). | `string` | n/a | yes |
3031
| parameter\_group\_name | Parameter group to use for this Redis cache. | `string` | `"default.redis5.0"` | no |

aws-redis-node/main.tf

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ module "sg" {
2929
}
3030
]
3131

32+
ingress_with_cidr_blocks = [
33+
for cidr_block in var.ingress_security_group_cidr_blocks : {
34+
from_port = var.port
35+
to_port = var.port
36+
protocol = "tcp"
37+
description = "Redis port"
38+
cidr_blocks = cidr_block
39+
}
40+
]
41+
3242
egress_rules = ["all-all"]
3343
}
3444

aws-redis-node/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ variable "ingress_security_group_ids" {
3535
description = "Source security groups which should be able to contact this instance."
3636
}
3737

38+
variable "ingress_security_group_cidr_blocks" {
39+
type = list(string)
40+
description = "Source CIDR blocks which should be able to contact this instance."
41+
default = []
42+
}
43+
3844
variable "port" {
3945
type = number
4046
description = "Port to host Redis on."

0 commit comments

Comments
 (0)