The code example below allows all outbound traffic from the associated EC2 instances or other resources that are associated with this security group
resource "aws_security_group" "insecure_example" {
egress {
cidr_blocks = ["0.0.0.0/0"]
}
}
Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges explicitly requiring it where possible.
Restricts egress traffic to a specific IP address
resource "aws_security_group" "secure_example" {
egress {
cidr_blocks = ["1.2.3.4/32"]
}
}