-
Notifications
You must be signed in to change notification settings - Fork 21
/
security_group.tf
23 lines (23 loc) · 923 Bytes
/
security_group.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_security_group
resource "aws_default_security_group" "default" {
vpc_id = aws_vpc.this.id
}
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
resource "aws_security_group" "instance-sg" {
name = "${var.name}-ec2-access"
description = "allow traffic to the ec2 instance"
vpc_id = aws_vpc.this.id
tags = {
"Name" = "${var.name}-ec2-sg"
}
}
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule
resource "aws_security_group_rule" "egress_instance_sg" {
description = "allow traffic from the vpc to reach outside the vpc"
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = aws_security_group.instance-sg.id
}