Skip to content

Commit

Permalink
NIT-1038 + NIT-1041 example SG allowing connectivity with legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Grzeskowiak committed Feb 6, 2024
1 parent c5a91cd commit 82af61e
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"accounts": {
"development": {
"example_var": "dev-data"
"legacy_counterpart_cidr": "10.162.32.0/20"
},
"test": {
"example_var": "test-data"
Expand Down
68 changes: 68 additions & 0 deletions terraform/environments/delius-mis/temp-ec2.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Example security group with rules required for connectivity with legacy
resource "aws_security_group" "example" {
name = "example"
description = "Example SG for legacy connectivity"
vpc_id = data.aws_vpc.shared.id
tags = merge(local.tags,
{ Name = lower(format("sg-%s-%s-example", local.application_name, local.environment)) }
)
}

resource "aws_vpc_security_group_ingress_rule" "icmp" {
security_group_id = aws_security_group.example.id
cidr_ipv4 = local.application_data.accounts[local.environment].legacy_counterpart_cidr
ip_protocol = "icmp"
from_port = -1
to_port = -1
}

resource "aws_vpc_security_group_egress_rule" "icmp" {
security_group_id = aws_security_group.example.id
cidr_ipv4 = local.application_data.accounts[local.environment].legacy_counterpart_cidr
ip_protocol = "icmp"
from_port = -1
to_port = -1
}

resource "aws_vpc_security_group_egress_rule" "http" {
for_each = toset(["80", "443"])

security_group_id = aws_security_group.example.id
cidr_ipv4 = "0.0.0.0/0"
ip_protocol = "tcp"
from_port = each.key
to_port = each.key
}

resource "aws_vpc_security_group_egress_rule" "oracle_db" {
for_each = toset(["1521"])

description = "Legacy Oracle DB"
security_group_id = aws_security_group.example.id
cidr_ipv4 = local.application_data.accounts[local.environment].legacy_counterpart_cidr
ip_protocol = "tcp"
from_port = each.key
to_port = each.key
}

resource "aws_vpc_security_group_egress_rule" "ad_tcp" {
for_each = toset(["53", "88", "135", "389", "445", "464", "636"])

description = "Legacy AD TCP"
security_group_id = aws_security_group.example.id
cidr_ipv4 = local.application_data.accounts[local.environment].legacy_counterpart_cidr
ip_protocol = "tcp"
from_port = each.key
to_port = each.key
}

resource "aws_vpc_security_group_egress_rule" "ad_udp" {
for_each = toset(["53", "88", "123", "138", "389", "445","464"])

description = "Legacy AD UDP"
security_group_id = aws_security_group.example.id
cidr_ipv4 = local.application_data.accounts[local.environment].legacy_counterpart_cidr
ip_protocol = "udp"
from_port = each.key
to_port = each.key
}

0 comments on commit 82af61e

Please sign in to comment.