NEW: more samples
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
locals {
|
||||
csv_file = file("sg.csv")
|
||||
rules = csvdecode(local.csv_file)
|
||||
}
|
||||
|
||||
data aws_caller_identity self {}
|
||||
|
||||
resource "aws_security_group" "security-groups" {
|
||||
description = "sg description"
|
||||
name = "sg1"
|
||||
vpc_id = data.aws_caller_identity.self.id
|
||||
|
||||
for_each = {
|
||||
for rule in local.rules : rule.rule_no => rule
|
||||
}
|
||||
|
||||
ingress {
|
||||
description = each.value.description
|
||||
from_port = each.value.from_port
|
||||
to_port = each.value.to_port
|
||||
protocol = each.value.proto
|
||||
cidr_blocks = [each.value.source]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
data aws_caller_identity self {}
|
||||
|
||||
variable sg1 {}
|
||||
|
||||
resource "aws_security_group" "sg1" {
|
||||
name = var.sg1.name
|
||||
description = var.sg1.description
|
||||
vpc_id = data.aws_caller_identity.self.id
|
||||
|
||||
dynamic "ingress" {
|
||||
for_each = var.sg1.cidrs
|
||||
content {
|
||||
description = ingress.key
|
||||
cidr_blocks = [ingress.value]
|
||||
from_port = var.sg1.from_port
|
||||
to_port = var.sg1.to_port
|
||||
protocol = "tcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
rule_no,direction,proto,from_port,to_port,source,description
|
||||
rule1,ingress,TCP,0,65535,10.193.35.0/24,MTCPortal
|
||||
rule2,ingress,TCP,0,65535,10.193.36.0/24,MTCVDI
|
||||
rule3,ingress,TCP,0,65535,10.193.46.0/24,iDesk
|
||||
|
Reference in New Issue
Block a user