mirror of
https://github.com/farcasclaudiu/terraform-course.git
synced 2026-06-22 07:01:56 +03:00
updates
This commit is contained in:
@@ -31,3 +31,17 @@ resource "aws_volume_attachment" "jenkins-data-attachment" {
|
|||||||
instance_id = "${aws_instance.jenkins-instance.id}"
|
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}"
|
||||||
|
}
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -9,11 +9,11 @@ if [ "`echo -n $DEVICE_FS`" == "" ] ; then
|
|||||||
lvcreate --name volume1 -l 100%FREE data
|
lvcreate --name volume1 -l 100%FREE data
|
||||||
mkfs.ext4 /dev/data/volume1
|
mkfs.ext4 /dev/data/volume1
|
||||||
fi
|
fi
|
||||||
mkdir -p /data
|
mkdir -p /var/lib/jenkins
|
||||||
echo '/dev/data/volume1 /data ext4 defaults 0 0' >> /etc/fstab
|
echo '/dev/data/volume1 /var/lib/jenkins ext4 defaults 0 0' >> /etc/fstab
|
||||||
mount /data
|
mount /var/lib/jenkins
|
||||||
|
|
||||||
cd /tmp
|
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
|
||||||
wget http://pkg.jenkins-ci.org/debian-stable/binary/${JENKINS_VERSION}
|
echo "deb http://pkg.jenkins.io/debian-stable binary/" >> /etc/apt/sources.list
|
||||||
dpkg -i ${JENKINS_VERSION}
|
apt-get update
|
||||||
rm ${JENKINS_VERSION}
|
apt-get install -y jenkins=${JENKINS_VERSION}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
resource "aws_security_group" "jenkins-securitygroup" {
|
resource "aws_security_group" "jenkins-securitygroup" {
|
||||||
vpc_id = "${aws_vpc.main.id}"
|
vpc_id = "${aws_vpc.main.id}"
|
||||||
name = "allow-ssh"
|
name = "jenkins-securitygroup"
|
||||||
description = "security group that allows ssh and all egress traffic"
|
description = "security group that allows ssh and all egress traffic"
|
||||||
egress {
|
egress {
|
||||||
from_port = 0
|
from_port = 0
|
||||||
@@ -15,7 +15,40 @@ resource "aws_security_group" "jenkins-securitygroup" {
|
|||||||
protocol = "tcp"
|
protocol = "tcp"
|
||||||
cidr_blocks = ["0.0.0.0/0"]
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
}
|
}
|
||||||
|
ingress {
|
||||||
|
from_port = 8080
|
||||||
|
to_port = 8080
|
||||||
|
protocol = "tcp"
|
||||||
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
|
}
|
||||||
tags {
|
tags {
|
||||||
Name = "jenkins-securitygroup"
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,5 +19,12 @@ variable "INSTANCE_DEVICE_NAME" {
|
|||||||
default = "/dev/xvdh"
|
default = "/dev/xvdh"
|
||||||
}
|
}
|
||||||
variable "JENKINS_VERSION" {
|
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"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user