Part 2: Terraform

 

Part 2: Terraform

 
Before we tackle the Terraform, make sure you have a security group set up for SSH and TCP. In the requirements they say "default", but that is usually used for VPC internal communication of services. You can decide how you want to handle security, but I've created a secondary SG with the specific requirements.
 

 
The Terraform piece is almost an exact copy from DevOps 01 so if you need a refresher, check that post out.
 
back out in our projects root level folder, create the terraform dir and then its child static-site:
mkdir terraform
cd terraform
mkdir static-site
cd static-site
touch main.tf variables.tf
main.tf
 
Note that you have to fill in your SG id's
terraform {
  required_version = "0.12.20"
}

provider "aws" {
    region=var.region
    profile=var.profile
}

resource "aws_instance" "site" {
    ami = "ami-042e8287309f5df03"
    instance_type="t2.micro"
    key_name="devops"
    vpc_security_group_ids = ["sg-f72319ab","sg-0586fa0aa906bfb79"]
        tags = {
            Name = var.name
            group = var.group
        }
}
 
variables.tf
variable "profile" {
    description = "The profile used to auth to AWS"
}

variable "region" {
    description= "The region our instance will be in (i.e. us-east-1)"
}

variable "name" {
    description= "The name of the instance we are creating"
}

variable "group" {
    description= "the name of the group we will be using for Ansible purposes"
}
 
And that is all for Terraform. EASY.
 

 

Part 3: Ansible and Dynamic Inventory

Comments

Popular posts from this blog

Terraform

Scrum Master Interview help - Bootcamp

Kubernetes