-
Notifications
You must be signed in to change notification settings - Fork 1
/
~
30 lines (28 loc) · 960 Bytes
/
~
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
# EC2 Instance
resource "aws_instance" "myec2vm" {
ami = data.aws_ami.amzlinux2.id
instance_type = var.instance_type
user_data = file("${path.module}/app1-install.sh")
key_name = var.instance_keypair
vpc_security_group_ids = [ aws_security_group.vpc-ssh.id, aws_security_group.vpc-web.id ]
tags = {
"Name" = "jenkin_server"
}
provisioner "remote-exec" {
inline = [
"sudo yum install -y jenkins java-11-openjdk-devel",
"sudo yum -y install wget",
"sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo",
"sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key",
"sudo yum upgrade -y",
"sudo yum install jenkins -y",
"sudo systemctl start jenkins",
]
}
connection {
type = "ssh"
host = self.public_ip
user = "ec2-user"
private_key = file("private-key/devops-titan-aws-key.pem")
}
}