in dataops-infra/infra/stacks/vpc_stack.py [0:0]
def create_security_groups(self) -> None:
self.airflow_sg = ec2.SecurityGroup(
self,
"airflow-sg-cdk",
security_group_name="airflow-sg-cdk",
description="Airflow SG",
vpc=self.instance,
allow_all_outbound=True,
)
self.alb_sg = ec2.SecurityGroup(
self,
"airflow-alb-sg-cdk",
security_group_name="airflow-alb-sg-cdk",
description="Airflow ALB SG",
vpc=self.instance,
allow_all_outbound=True,
)
self.vpc_endpoint_sg = ec2.SecurityGroup(
self,
"vpc-endpoint-sg",
security_group_name="vpc-endpoint-sg",
description="VPC Endpoint SG",
vpc=self.instance,
allow_all_outbound=False,
)
self.postgres_sg = ec2.SecurityGroup(
self,
"airflow-db-sg",
security_group_name="airflow-db-sg-cdk",
description="Airflow Postgres SG",
vpc=self.instance,
allow_all_outbound=True,
)
self.redshift_sg = ec2.SecurityGroup(
self,
"redshift-sg",
security_group_name="redshift-sg-cdk",
description="Redshift cluster SG",
vpc=self.instance,
allow_all_outbound=True,
)
self.redis_sg = ec2.SecurityGroup(
self,
"redis-sg",
security_group_name="redis-sg-cdk",
description="Redis SG",
vpc=self.instance,
allow_all_outbound=True,
)
self.airflow_sg.connections.allow_from(
self.airflow_sg, ec2.Port.all_traffic(), "Ingress"
)
self.airflow_sg.connections.allow_from(
self.alb_sg, ec2.Port.tcp(8080), "Ingress"
)
self.airflow_sg.connections.allow_from(
self.redshift_sg, ec2.Port.tcp(5439), "Ingress"
)
self.airflow_sg.connections.allow_from(
self.redis_sg, ec2.Port.tcp(6379), "Ingress"
)
self.airflow_sg.connections.allow_from(
self.vpc_endpoint_sg, ec2.Port.tcp(443), "Ingress"
)
self.redis_sg.connections.allow_from(
self.airflow_sg, ec2.Port.tcp(6379), "Ingress"
)
self.redshift_sg.connections.allow_from(
self.airflow_sg, ec2.Port.tcp(5439), "Ingress"
)
self.postgres_sg.connections.allow_from(
self.airflow_sg, ec2.Port.tcp(5432), "Ingress"
)