-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.tf
43 lines (37 loc) · 1.1 KB
/
resources.tf
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
// AWS security group resource for backend node
resource "aws_security_group" "backend_node_sg" {
name = "backend_node_sg"
description = "Allow SSH traffic from all IP addresses"
// VPC ID where you want to create the security group
vpc_id = var.vpc_id
// Inbound SSH rule from all IP addresses
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
description = "Allow all outbound traffic by default"
ipv6_cidr_blocks = ["::/0"]
prefix_list_ids = []
}
}
output "backend_node_sg_id" {
value = aws_security_group.backend_node_sg.id
}
resource "aws_instance" "backend_node" {
ami = var.ami_map.backend_node.ami_id
instance_type = var.instance_type_map.backend_node
key_name = var.keypair_web2
tags = {
Name = "backend_node"
}
subnet_id = var.public_subnet_id
security_groups = [aws_security_group.backend_node_sg.id]
user_data = file("init.sh")
}