Lindsey  Koepp

Lindsey Koepp

1603291380

Intro to Terraform: Provision EC2 Instance and Install Jenkins

How to easily provision an EC2 Instance and execute remote commands to install Jenkins

Image for post

Photo by Lance Anderson on Unsplash

Intro

Terraform is a tool that allows you to quickly build and provision your Infrastructure as Code and is compatible with many providers such as AWS, Google Cloud, Digital Ocean, and more.

In this article, I will walk you through how we can easily and quickly leverage Terraform to provision an EC2 instance on AWS running Ubuntu and install Jenkins.

Prerequisites

Provision EC2 Instance

At the time of this writing, I am running Terraform v0.13.4. Let’s start off by creating a folder for our working directory and create a main.tf file.

➜  ~ mkdir terraform-intro
➜  ~ cd terraform-intro
➜  terraform-into touch main.tf

Open main.tf in your favorite text editor and paste in the following.

provider "aws" {
	  profile = "default"
	  region  = "us-east-1"
	}

	data "aws_ami" "ubuntu" {
	  most_recent = true

	  filter {
	    name   = "name"
	    values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
	  }

	  filter {
	    name   = "virtualization-type"
	    values = ["hvm"]
	  }

	  owners = ["099720109477"]
	}

	resource "aws_instance" "jenkins" {
	  ami           = data.aws_ami.ubuntu.id
	  instance_type = "t2.micro"

	  tags = {
	    "Name"      = "Jenkins_Server"
	    "Terraform" = "true"
	  }
	}

#terraform #infrastructure #ec2 #aws #infrastructure-as-code

What is GEEK

Buddha Community

Intro to Terraform: Provision EC2 Instance and Install Jenkins
Lindsey  Koepp

Lindsey Koepp

1603291380

Intro to Terraform: Provision EC2 Instance and Install Jenkins

How to easily provision an EC2 Instance and execute remote commands to install Jenkins

Image for post

Photo by Lance Anderson on Unsplash

Intro

Terraform is a tool that allows you to quickly build and provision your Infrastructure as Code and is compatible with many providers such as AWS, Google Cloud, Digital Ocean, and more.

In this article, I will walk you through how we can easily and quickly leverage Terraform to provision an EC2 instance on AWS running Ubuntu and install Jenkins.

Prerequisites

Provision EC2 Instance

At the time of this writing, I am running Terraform v0.13.4. Let’s start off by creating a folder for our working directory and create a main.tf file.

➜  ~ mkdir terraform-intro
➜  ~ cd terraform-intro
➜  terraform-into touch main.tf

Open main.tf in your favorite text editor and paste in the following.

provider "aws" {
	  profile = "default"
	  region  = "us-east-1"
	}

	data "aws_ami" "ubuntu" {
	  most_recent = true

	  filter {
	    name   = "name"
	    values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
	  }

	  filter {
	    name   = "virtualization-type"
	    values = ["hvm"]
	  }

	  owners = ["099720109477"]
	}

	resource "aws_instance" "jenkins" {
	  ami           = data.aws_ami.ubuntu.id
	  instance_type = "t2.micro"

	  tags = {
	    "Name"      = "Jenkins_Server"
	    "Terraform" = "true"
	  }
	}

#terraform #infrastructure #ec2 #aws #infrastructure-as-code

Rory  West

Rory West

1621745280

Create EC2 instance from AWS Console

What is EC2 Instance?

Secure and resizable compute capacity in the cloud.

Amazon Elastic Compute Cloud ( Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.

In this article let us see how to create On-demand EC2 instance from Console.

#create-ec2-instance #aws-ec2-instance #ec2-instance #amazon-web-services #aws

Kole  Haag

Kole Haag

1603213200

Using Terraform to Create an EC2 Instance With Cloudwatch Alarm Metrics

Hey guys! I wanted to do a quick tutorial on how I created an EC2 module for Terraform. If you want to see the repository it is located in check it out here. This module will do a few things:

  1. Create an EC2 Instance
  2. Automatically look up the latest Windows Server 2019 AMI for the EC2 instance.
  3. Create and attach a additional drive.
  4. Create a Cloudwatch Alarm Metric to monitor CPU.

The folder structure looks like this:

Image for post

First things first… I created the main.tf file which contains all of my configuration except for the variables and outputs. The main.tf has a few parts to it.

AWS Instance Code

The first section is the instance resource code

#AWS Instance

resource "aws_instance" "example" {
     ami = data.aws_ami.windows.id
     instance_type = "t2.micro"
     availability_zone = var.availability_zone
}

You will notice a few things here.

  1. The instance type is set in the module to t2.micro
  2. availability_zone is set using a variable
  3. ami is set using data

We will get the the availability zone piece in just a bit, first we are going to tackle the data used for the ami argument.

Data for AMI Using a Filter

The next bit of code for the filter looks like this

#AMI Filter for Windows Server 2019 Base

data "aws_ami" "windows" {
     most_recent = true
     filter {
       name   = "name"
       values = ["Windows_Server-2019-English-Full-Base-*"]
  }
     filter {
       name   = "virtualization-type"
       values = ["hvm"]
  }
     owners = ["801119661308"] ## Canonical
}

The argument most_recent is set to true. This means that it will grab the most recent AMI that fits the criteria that we specify in our filter.

Next you will notice that in the name we set the value to *Windows_Server-2019-English-Full-Base- **with the star at the end. This lets Terraform know we don’t care about what text comes after that point and it was done because the standard format puts the date there. If we set the date the ami was created and set the most_recent argument to true it would not do us any good.

After that we set the virtualization-type to hvm. I am not going to go into a lot of detail here. Just know this is a good idea and do some additional research on hvm vs pv.

Last we set **owners **to 801119661308.

Now I am sure you are asking… how the heck do I actually get this information? Well you are going to have to run a quick command with the AWS cli.

First, login to AWS and get the ami you want to grab the information for. Here is an example:

Image for post

If you click on launch instance you can do a search.

#aws-ec2 #hashicorp-terraform #aws-cloudwatch #terraform-modules #terraform

Jenkins Is Getting Old — It’s Time to Move On

By far, Jenkins is the most adopted tool for continuous integration, owning nearly 50% of the market share. As so many developers are using it, it has excellent community support, like no other Jenkins alternative. With that, it has more than 1,500 plugins available for continuous integration and delivery purposes.

We love and respect Jenkins. After all, it’s the first tool we encountered at the beginning of our automation careers. But as things are rapidly changing in the automation field, Jenkins is** left behind with his old approach**. Even though many developers and companies are using it, most of them aren’t happy with it. Having used it ourselves on previous projects, we quickly became frustrated by its lack of functionality, numerous maintenance issues, dependencies, and scaling problems.

We decided to investigate if other developers face the same problems and quickly saw the need to create a tool ourselves. We asked some developers at last year’s AWS Summit in Berlin about this. Most of them told us that they chose Jenkins because it’s free in the first place. However, many of them expressed interest in trying to use some other Jenkins alternative.

#devops #continuous integration #jenkins #devops adoption #jenkins ci #jenkins pipeline #devops continuous integration #jenkins automation #jenkins scripts #old technology

Sherman  Zemlak

Sherman Zemlak

1628764740

Introduction to Terraform - Provision EC2 Instance on AWS

Today we’ll be giving an introduction to HashiCorp Terraform. Learn about IaC (infrastructure as code) & it’s advantages. We’ll be provisioning an AWS EC2 instance running nginx using Terraform.

Source code:
https://github.com/kriscfoster/terraform-aws-hello-world

Don’t forget to Subscribe here: https://www.youtube.com/channel/UCWkzkhQ3syxBjjAYwqCbzYg?sub_confirmation=1

https://www.terraform.io/
https://aws.amazon.com/

#ec2 #aws #terraform