-
Notifications
You must be signed in to change notification settings - Fork 845
Expand file tree
/
Copy pathec2_jenkins.tf
More file actions
38 lines (30 loc) · 1.12 KB
/
ec2_jenkins.tf
File metadata and controls
38 lines (30 loc) · 1.12 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
resource "aws_instance" "ec2_jenkins" {
ami = "${lookup(var.ami_id, var.region)}"
instance_type = "${var.instance_type}"
# Security group assign to instance
vpc_security_group_ids = [aws_security_group.allow_ssh.id]
# key name
key_name = "${var.key_name}"
user_data = <<EOF
#! /bin/bash
sudo yum update -y
sudo yum install -y httpd.x86_64
sudo service httpd start
sudo service httpd enable
echo "<h1>Deployed via Terraform</h1>" | sudo tee /var/www/html/index.html
yum install java-1.8.0-openjdk-devel -y
curl --silent --location http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo | sudo tee /etc/yum.repos.d/jenkins.repo
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
yum install -y jenkins
yum install -y git
wget https://releases.hashicorp.com/terraform/0.12.29/terraform_0.12.29_linux_amd64.zip
unzip terraform_0.12.29_linux_amd64.zip
mv terraform /usr/bin
systemctl start jenkins
systemctl status jenkins
systemctl enable jenkins
EOF
tags = {
Name = "Ec2-User-data"
}
}