-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathec2.tf
More file actions
55 lines (48 loc) · 1.48 KB
/
ec2.tf
File metadata and controls
55 lines (48 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
resource "aws_instance" "website_server" {
ami = "ami-0b016c703b95ecbe4" #Amazon Linux 2 AMI
instance_type = "t2.micro"
key_name = "chave-site-prod"
vpc_security_group_ids = [aws_security_group.website_sg.id]
iam_instance_profile = "ECR-EC2-Role"
tags = {
Name = "website-server"
Provisioned = "Terraform"
Cliente = "Maria"
}
}
## Security Group
resource "aws_security_group" "website_sg" {
name = "website-sg"
vpc_id = "vpc-0ff60a695425883cf"
tags = {
Name = "website-sg"
Provisioned = "Terraform"
Cliente = "Maria"
}
}
resource "aws_vpc_security_group_ingress_rule" "allow_ssh" {
security_group_id = aws_security_group.website_sg.id
cidr_ipv4 = "172.31.0.0/16"
from_port = 22
ip_protocol = "tcp"
to_port = 22
}
resource "aws_vpc_security_group_ingress_rule" "allow_http" {
security_group_id = aws_security_group.website_sg.id
cidr_ipv4 = "0.0.0.0/0"
from_port = 80
ip_protocol = "tcp"
to_port = 80
}
resource "aws_vpc_security_group_ingress_rule" "allow_https" {
security_group_id = aws_security_group.website_sg.id
cidr_ipv4 = "0.0.0.0/0"
from_port = 443
ip_protocol = "tcp"
to_port = 443
}
resource "aws_vpc_security_group_egress_rule" "allow_all_outbound" {
security_group_id = aws_security_group.website_sg.id
cidr_ipv4 = "0.0.0.0/0"
ip_protocol = -1
}