This commit is contained in:
Edward Viaene
2016-10-19 10:37:06 +00:00
parent 88bdf09a48
commit 1a61ad96ec
6 changed files with 69 additions and 12 deletions
+14
View File
@@ -31,3 +31,17 @@ resource "aws_volume_attachment" "jenkins-data-attachment" {
instance_id = "${aws_instance.jenkins-instance.id}"
}
resource "aws_instance" "app-instance" {
count = "${var.APP_INSTANCE_COUNT}"
ami = "${var.APP_INSTANCE_AMI}"
instance_type = "t2.micro"
# the VPC subnet
subnet_id = "${aws_subnet.main-public-1.id}"
# the security group
vpc_security_group_ids = ["${aws_security_group.app-securitygroup.id}"]
# the public SSH key
key_name = "${aws_key_pair.mykeypair.key_name}"
}
+6
View File
@@ -0,0 +1,6 @@
output "jenkins-ip" {
value = "${aws_instance.jenkins-instance.public_ip}"
}
output "app-ip" {
value = "${aws_instance.app-instance.public_ip}"
}
@@ -1,3 +0,0 @@
#!/bin/bash
apt-get update
apt-get install -y nginx docker.io vim lvm2
+7 -7
View File
@@ -9,11 +9,11 @@ if [ "`echo -n $DEVICE_FS`" == "" ] ; then
lvcreate --name volume1 -l 100%FREE data
mkfs.ext4 /dev/data/volume1
fi
mkdir -p /data
echo '/dev/data/volume1 /data ext4 defaults 0 0' >> /etc/fstab
mount /data
mkdir -p /var/lib/jenkins
echo '/dev/data/volume1 /var/lib/jenkins ext4 defaults 0 0' >> /etc/fstab
mount /var/lib/jenkins
cd /tmp
wget http://pkg.jenkins-ci.org/debian-stable/binary/${JENKINS_VERSION}
dpkg -i ${JENKINS_VERSION}
rm ${JENKINS_VERSION}
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
echo "deb http://pkg.jenkins.io/debian-stable binary/" >> /etc/apt/sources.list
apt-get update
apt-get install -y jenkins=${JENKINS_VERSION}
+34 -1
View File
@@ -1,6 +1,6 @@
resource "aws_security_group" "jenkins-securitygroup" {
vpc_id = "${aws_vpc.main.id}"
name = "allow-ssh"
name = "jenkins-securitygroup"
description = "security group that allows ssh and all egress traffic"
egress {
from_port = 0
@@ -15,7 +15,40 @@ resource "aws_security_group" "jenkins-securitygroup" {
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
Name = "jenkins-securitygroup"
}
}
resource "aws_security_group" "app-securitygroup" {
vpc_id = "${aws_vpc.main.id}"
name = "app-securitygroup"
description = "security group that allows ssh and all egress traffic"
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
Name = "app-securitygroup"
}
}
+8 -1
View File
@@ -19,5 +19,12 @@ variable "INSTANCE_DEVICE_NAME" {
default = "/dev/xvdh"
}
variable "JENKINS_VERSION" {
default = "jenkins_2.7.4_all.deb"
default = "2.19.1"
}
variable "APP_INSTANCE_AMI" {
default = "ami-2291de51"
}
variable "APP_INSTANCE_COUNT" {
default = "0"
}