Skip to content

Commit

Permalink
[feature] Add CIDR blocks based security group to Redis (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebezzi authored Feb 9, 2021
1 parent 488c4ea commit 298ee9d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions aws-redis-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ parameters.
| 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 |
| env | Env for tagging and naming. See [doc](../README.md#consistent-tagging). | `string` | n/a | yes |
| ingress\_security\_group\_ids | Source security groups which should be able to contact this instance. | `list(string)` | n/a | yes |
| ingress\_security\_group\_cidr_blocks | CIDR blocks which should be able to contact this instance. | `list(string)` | [] | no |
| 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 |
| owner | Owner for tagging and naming. See [doc](../README.md#consistent-tagging). | `string` | n/a | yes |
| parameter\_group\_name | Parameter group to use for this Redis cache. | `string` | `"default.redis5.0"` | no |
Expand Down
10 changes: 10 additions & 0 deletions aws-redis-node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ module "sg" {
}
]

ingress_with_cidr_blocks = [
for cidr_block in var.ingress_security_group_cidr_blocks : {
from_port = var.port
to_port = var.port
protocol = "tcp"
description = "Redis port"
cidr_blocks = cidr_block
}
]

egress_rules = ["all-all"]
}

Expand Down
6 changes: 6 additions & 0 deletions aws-redis-node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ variable "ingress_security_group_ids" {
description = "Source security groups which should be able to contact this instance."
}

variable "ingress_security_group_cidr_blocks" {
type = list(string)
description = "Source CIDR blocks which should be able to contact this instance."
default = []
}

variable "port" {
type = number
description = "Port to host Redis on."
Expand Down

0 comments on commit 298ee9d

Please sign in to comment.