Skip to content

Commit 5803b28

Browse files
authored
Add self sg ingress rule option (#7)
1 parent 2005687 commit 5803b28

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Module managed by [Marcin Cuber](https://github.com/marcincuber) [linkedin](http
8989
| description | The description of the all resources. | `string` | `"Managed by Terraform"` | no |
9090
| engine\_version | The version number of the cache engine to be used for the cache clusters in this replication group. | `string` | `"5.0.6"` | no |
9191
| family | The family of the ElastiCache parameter group. | `string` | `"redis5.0"` | no |
92+
| ingress\_self | Specify whether the security group itself will be added as a source to the ingress rule. | `bool` | `false` | no |
9293
| ingress\_cidr\_blocks | List of Ingress CIDR blocks. | `list(string)` | `[]` | no |
9394
| kms\_key\_id | The ARN of the key that you wish to use if encrypting at rest. If not supplied, uses service managed encryption. Can be specified only if `at_rest_encryption_enabled = true` | `string` | `""` | no |
9495
| maintenance\_window | Specifies the weekly time range for when maintenance on the cache cluster is performed. | `string` | `""` | no |
@@ -145,4 +146,4 @@ brew install pre-commit terraform-docs tflint
145146

146147
brew tap git-chglog/git-chglog
147148
brew install git-chglog
148-
```
149+
```

main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ resource "aws_security_group" "redis" {
7373
}
7474
}
7575

76+
resource "aws_security_group_rule" "redis_ingress_self" {
77+
count = var.ingress_self ? 1 : 0
78+
79+
type = "ingress"
80+
from_port = var.port
81+
to_port = var.port
82+
protocol = "tcp"
83+
self = true
84+
security_group_id = aws_security_group.redis.id
85+
}
86+
7687
resource "aws_security_group_rule" "redis_ingress_cidr_blocks" {
7788
count = length(var.ingress_cidr_blocks) != 0 ? 1 : 0
7889

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ variable "ingress_cidr_blocks" {
2929
default = []
3030
}
3131

32+
variable "ingress_self" {
33+
type = bool
34+
description = "Specify whether the security group itself will be added as a source to the ingress rule."
35+
default = false
36+
}
37+
3238
variable "security_group_ids" {
3339
type = list(string)
3440
description = "List of Security Groups."

0 commit comments

Comments
 (0)