Skip to content

Commit a25f37f

Browse files
osocodeChris BurtonAbdul Wahid
authored
Allow other sg ingress (#24)
* Allow to configure for ingress from other SGs * Update README and basic example * Add documentation Co-authored-by: Chris Burton <chris.burton@atmosphere.tv> Co-authored-by: Abdul Wahid <abdul.wahid@umotif.com>
1 parent adbfc9a commit a25f37f

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

CHANGELOG.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ All notable changes to this project will be documented in this file.
55
<a name="unreleased"></a>
66
## [Unreleased]
77

8-
- Updated Readme
9-
- More changes
10-
- Fix dynamic
11-
- Initial commit
8+
- Update README and basic example
9+
- Allow to configure for ingress from other SGs
10+
- Support Redis log delivery ([#26](https://github.com/umotif-public/terraform-aws-elasticache-redis/issues/26))
1211

1312

1413
<a name="3.0.0"></a>

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ No modules.
103103
| [aws_elasticache_replication_group.redis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_replication_group) | resource |
104104
| [aws_elasticache_subnet_group.redis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_subnet_group) | resource |
105105
| [aws_security_group.redis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
106+
| [aws_security_group_rule.other_sg_ingress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
106107
| [aws_security_group_rule.redis_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
107108
| [aws_security_group_rule.redis_ingress_cidr_blocks](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
108109
| [aws_security_group_rule.redis_ingress_self](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
@@ -112,6 +113,7 @@ No modules.
112113

113114
| Name | Description | Type | Default | Required |
114115
|------|-------------|------|---------|:--------:|
116+
| <a name="input_allowed_security_groups"></a> [allowed\_security\_groups](#input\_allowed\_security\_groups) | List of existing security groups that will be allowed ingress via the elaticache security group rules | `list(string)` | `[]` | no |
115117
| <a name="input_apply_immediately"></a> [apply\_immediately](#input\_apply\_immediately) | Specifies whether any modifications are applied immediately, or during the next maintenance window. | `bool` | `false` | no |
116118
| <a name="input_at_rest_encryption_enabled"></a> [at\_rest\_encryption\_enabled](#input\_at\_rest\_encryption\_enabled) | Whether to enable encryption at rest. | `bool` | `true` | no |
117119
| <a name="input_auth_token"></a> [auth\_token](#input\_auth\_token) | The password used to access a password protected server. Can be specified only if `transit_encryption_enabled = true`. | `string` | `""` | no |

examples/redis-basic/main.tf

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ data "aws_subnets" "all" {
1818
values = [data.aws_vpc.default.id]
1919
}
2020
}
21+
22+
#####
23+
# External Security Group
24+
#####
25+
resource "aws_security_group" "other_sg" {
26+
vpc_id = data.aws_vpc.default.id
27+
}
28+
2129
#####
2230
# Elasticache Redis
2331
#####
@@ -49,6 +57,8 @@ module "redis" {
4957
subnet_ids = data.aws_subnets.all.ids
5058
vpc_id = data.aws_vpc.default.id
5159

60+
allowed_security_groups = [aws_security_group.other_sg.id]
61+
5262
ingress_cidr_blocks = ["0.0.0.0/0"]
5363

5464
parameter = [

main.tf

+10
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,13 @@ resource "aws_security_group_rule" "redis_egress" {
137137
cidr_blocks = ["0.0.0.0/0"]
138138
security_group_id = aws_security_group.redis.id
139139
}
140+
141+
resource "aws_security_group_rule" "other_sg_ingress" {
142+
count = length(var.allowed_security_groups)
143+
type = "ingress"
144+
from_port = var.port
145+
to_port = var.port
146+
protocol = "tcp"
147+
source_security_group_id = element(var.allowed_security_groups, count.index)
148+
security_group_id = aws_security_group.redis.id
149+
}

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,9 @@ variable "log_delivery_configuration" {
208208
error_message = "You can set 2 targets at most for log delivery options."
209209
}
210210
}
211+
212+
variable "allowed_security_groups" {
213+
type = list(string)
214+
description = "List of existing security groups that will be allowed ingress via the elaticache security group rules"
215+
default = []
216+
}

0 commit comments

Comments
 (0)