File tree 2 files changed +12
-7
lines changed
2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,15 @@ resource "aws_security_group" "redis_security_group" {
8
8
}
9
9
}
10
10
11
- resource "aws_security_group_rule" "redis_ingress " {
12
- count = length ( var. allowed_security_groups )
11
+ resource "aws_security_group_rule" "redis_inbound_from_sg " {
12
+ for_each = { for security_group_id in var . allow_security_group_ids : security_group_id . name => security_group_id }
13
13
type = " ingress"
14
14
from_port = var. redis_port
15
15
to_port = var. redis_port
16
16
protocol = " tcp"
17
- source_security_group_id = element (var . allowed_security_groups , count . index )
17
+ source_security_group_id = each . value . security_group_id
18
18
security_group_id = aws_security_group. redis_security_group . id
19
+ description = try (each. value . description , " From ${ each . value . security_group_id } " )
19
20
}
20
21
21
22
resource "aws_security_group_rule" "redis_networks_ingress" {
Original file line number Diff line number Diff line change @@ -23,12 +23,16 @@ variable "apply_immediately" {
23
23
variable "allowed_cidr" {
24
24
description = " A list of Security Group ID's to allow access to."
25
25
type = list (string )
26
- default = [" 127.0.0.1/32 " ]
26
+ default = []
27
27
}
28
28
29
- variable "allowed_security_groups" {
30
- description = " A list of Security Group ID's to allow access to."
31
- type = list (string )
29
+ variable "allow_security_group_ids" {
30
+ type = list (object ({
31
+ security_group_id = string
32
+ description = string
33
+ name = string
34
+ }))
35
+ description = " List of Security Group IDs to allow connection to."
32
36
default = []
33
37
}
34
38
You can’t perform that action at this time.
0 commit comments