Skip to content

Commit

Permalink
Outbound sg to 3306
Browse files Browse the repository at this point in the history
  • Loading branch information
prashansa joshi committed Sep 22, 2024
1 parent 0ad60ab commit a506c6f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
3 changes: 3 additions & 0 deletions terraform/eb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ module "elastic_beanstalk_environment" {

env_vars = var.env_vars

# Attach the security group for EB instances
security_group_ids = [aws_security_group.eb_instances.id]

extended_ec2_policy_document = data.aws_iam_policy_document.minimal_s3_permissions.json
prefer_legacy_ssm_policy = false
prefer_legacy_service_policy = false
Expand Down
28 changes: 19 additions & 9 deletions terraform/sg.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,30 @@ resource "aws_security_group" "database" {
#################################################
# EC2
#################################################
# Security Group for Elastic Beanstalk Instances
resource "aws_security_group" "eb_instances" {
name = "eb-instances-sg"
name = "${local.elastic_beanstalk_application.name}-sg"
description = "Security group for Elastic Beanstalk instances"
vpc_id = data.aws_vpc.adex_poc_default_vpc.id

# Allow outbound MySQL traffic to the RDS security group
egress {
from_port = 3306
to_port = 3306
protocol = "tcp"
security_groups = [aws_security_group.database.id]
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # Allow HTTP traffic
}

tags = {
Name = "EB Instances SG"
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # Allow HTTPS traffic
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"] # Allow all outbound traffic
}
}

0 comments on commit a506c6f

Please sign in to comment.