项目作者: isaccavalcante

项目描述 :
Devops challenge
高级语言: HCL
项目地址: git://github.com/isaccavalcante/challenge-live-infrastructure.git


Challenge Live Infrastructure

This repository contains configuration files defining the infrastructure as a code of the challenge for DevOps Engineer job position at Pagar.me.

Challenge description

Create a monitoring infrastructure. The objective is to deploy an Elastic Stack (ELK) and be able to aggregate log data from an EC2 instance.

What will be evaluated:

  • Usage of an IaC tool (we use Terraform & Packer)
  • Cloud knowledge (we use AWS)
  • Mastery of good practices of infrastructure and systems resilience
  • Practices of monitoring/observability
  • Code organization

Architecture

diagram

Getting started

Prerequisites

Install and setup the version manager asdf by running the following commands:

  1. git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0
  2. echo ". $HOME/.asdf/asdf.sh" >> ~/.bashrc

Now install Terraform and Packer by running:

  1. asdf plugin add terraform
  2. asdf install terraform 0.13.5
  3. asdf global terraform 0.13.5
  4. asdf plugin add packer
  5. asdf install packer 1.6.5
  6. asdf global packer 1.6.5

Creating & Destroying

Initialize Terraform modules in the desired directory (e.g. isac.aws/us-east-1/dev) by running:

  1. terraform init

To apply all the infrastructure, run the following command:

  1. terraform apply -auto-approve

To destroy all the infrastructure, run the following command:

  1. terraform destroy -auto-approve

Elasticsearch tunnel

Add the following content to your ~/.ssh/config file changing the variables accordingly

  1. # Elasticsearch Tunnel
  2. Host estunnel
  3. HostName <EC2 IP address>
  4. User ec2-user
  5. IdentitiesOnly yes
  6. IdentityFile <my .pem key>
  7. LocalForward 9200 <Elasticsearch endpoint>

Then run the following command to create an SSH tunnel which allows you to reach Elasticsearch endpoint at https://localhost:9200

  1. ssh estunnel -N