Last active
July 31, 2020 13:40
-
-
Save KernelPanicAUS/a5bd52e3fc51a09f108922e4c62dc340 to your computer and use it in GitHub Desktop.
Revisions
-
KernelPanicAUS revised this gist
Jul 31, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ data "aws_vpc" "selected" { } locals { ingress_rules = [ { description = "test-one", from_port = 443, @@ -55,7 +55,7 @@ resource "aws_security_group" "test_two" { resource "aws_security_group_rule" "test_two_rules" { for_each = { for rule in local.ingress_rules : "${rule.description}-${rule.protocol}" => rule } -
KernelPanicAUS revised this gist
Jul 30, 2020 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ terraform { required_version = ">= 0.12" @@ -68,4 +67,3 @@ resource "aws_security_group_rule" "test_two_rules" { cidr_blocks = lookup(each.value, "cidr_blocks") security_group_id = aws_security_group.test_two.id } -
KernelPanicAUS revised this gist
Jul 30, 2020 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,7 +55,11 @@ resource "aws_security_group" "test_two" { } resource "aws_security_group_rule" "test_two_rules" { for_each = { for rule in local.ingress_map : "${rule.description}-${rule.protocol}" => rule } type = "ingress" description = lookup(each.value, "description") from_port = lookup(each.value, "from_port") -
KernelPanicAUS created this gist
Jul 30, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ ```hcl terraform { required_version = ">= 0.12" required_providers { aws = "~> 2.0" } } provider "aws" { region = "eu-central-1" } data "aws_vpc" "selected" { default = true } locals { ingress_map = [ { description = "test-one", from_port = 443, to_port = 443, protocol = "tcp" cidr_blocks = [data.aws_vpc.selected.cidr_block] }, { description = "test-two", from_port = 444, to_port = 444, protocol = "tcp" cidr_blocks = [data.aws_vpc.selected.cidr_block] }, { description = "test-three", from_port = 445, to_port = 445, protocol = "tcp" cidr_blocks = [data.aws_vpc.selected.cidr_block] }, { description = "test-four", from_port = 446, to_port = 446, protocol = "tcp" cidr_blocks = [data.aws_vpc.selected.cidr_block] } ] } resource "aws_security_group" "test_two" { name = "test_two" description = "Allow inbound traffic" vpc_id = data.aws_vpc.selected.id } resource "aws_security_group_rule" "test_two_rules" { for_each = { for rule in local.ingress_map : "${rule.description}-${rule.protocol}" => rule } type = "ingress" description = lookup(each.value, "description") from_port = lookup(each.value, "from_port") to_port = lookup(each.value, "to_port") protocol = lookup(each.value, "protocol") cidr_blocks = lookup(each.value, "cidr_blocks") security_group_id = aws_security_group.test_two.id } ```