Skip to content

Commit

Permalink
Added new code
Browse files Browse the repository at this point in the history
  • Loading branch information
nitin-das committed Nov 30, 2019
1 parent 29d98b0 commit 5cb1f22
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
26 changes: 14 additions & 12 deletions security-groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ resource "aws_security_group" "security_group" {
vpc_id = var.vpc_id
revoke_rules_on_delete = var.revoke_rules_on_delete

dynamic "ingress" {
for_each = var.ingress_rules
content {
from_port = ingress.value["from_port"]
to_port = ingress.value["to_port"]
protocol = ingress.value["protocol"]
cidr_blocks = [ingress.value["cidr_blocks"]]
description = ingress.value["description"]
self = ingress.value["self"]
security_groups = [split(",",ingress.value["security_groups"])]
}
}
// dynamic "ingress" {
// for_each = var.ingress_rules
// content {
// from_port = ingress.value["from_port"]
// to_port = ingress.value["to_port"]
// protocol = ingress.value["protocol"]
// cidr_blocks = [ingress.value["cidr_blocks"]]
// description = ingress.value["description"]
// self = ingress.value["self"]
// // security_groups = [split(",",ingress.value["security_groups"])]
// }
// }

ingress = var.ingress_rules

// dynamic "egress" {
// for_each = var.egress_rules
// content {
Expand Down
12 changes: 11 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ variable "common_tags" {

variable "ingress_rules" {
description = "Ingress rules for security group"
type = list(map(string))
type = list(object({
from_port = string
to_port = number
protocol = string
cidr_blocks = list(string)
description = string
self = bool
security_groups = list(string)
}))
}



variable "egress_rules" {
description = "Egress rules for security group"
type = list(map(string))
Expand Down

0 comments on commit 5cb1f22

Please sign in to comment.