Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add CIDR blocks based security group to Redis #286

Merged
merged 2 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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