Skip to content

Instantly share code, notes, and snippets.

@theCaptN21
Created February 2, 2023 14:34
Show Gist options
  • Save theCaptN21/6192d04e9fd93ff0136af5286881f3dd to your computer and use it in GitHub Desktop.
Save theCaptN21/6192d04e9fd93ff0136af5286881f3dd to your computer and use it in GitHub Desktop.
Jenkins instance
#Jenkins instance
resource "aws_instance" "jenkins_server" {
ami = "data.aws_ami.linux.id"
instance_type = "t2.micro"
vpc_security_group_ids = [aws_security_group.jenkins_sg.id]
tags = {
Name = "Jenkins Server"
}
iam_instance_profile = "${aws_iam_role.jenkins_role.name}"
user_data = <<EOF
#!/bin/bash
yum update -y
yum install -y java-1.8.0-openjdk
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install -y jenkins
systemctl start jenkins
systemctl enable jenkins
EOF
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment