-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
58 lines (50 loc) · 1.83 KB
/
main.tf
File metadata and controls
58 lines (50 loc) · 1.83 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
56
57
58
resource "aws_security_group" "devops-sg" {
name = "devops-sg"
description = "Allow inbound traffic"
dynamic "ingress" {
for_each = [22, 80, 443, 8080, 9000, 3000]
content {
description = "inbound rule for port ${ingress.value}"
from_port = ingress.value
to_port = ingress.value
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = []
prefix_list_ids = []
security_groups = []
self = false
}
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_instance" "Jenkins-master" {
ami = "ami-03bb6d83c60fc5f7c" # Replace with the AMI ID
instance_type = "t2.medium" # Instance type you want to launch
key_name = "ec2-global-key" # Replace with your SSH key pair name
vpc_security_group_ids = [aws_security_group.devops-sg.id] # Corrected reference to security group ID
user_data = templatefile("jenkins-master.sh", {})
tags = {
Name = "Jenkins-master"
}
root_block_device {
volume_size = 25
}
}
resource "aws_instance" "Jenkins-slave" {
ami = "ami-03bb6d83c60fc5f7c" # Replace with the AMI ID
instance_type = "t2.small" # Instance type you want to launch
key_name = "ec2-global-key" # Replace with your SSH key pair name
vpc_security_group_ids = [aws_security_group.devops-sg.id] # Corrected reference to security group ID
user_data = templatefile("jenkins-slave.sh", {})
tags = {
Name = "Jenkins-slave"
}
root_block_device {
volume_size = 15
}
}