Create AWS codebuild project with Terraform

Summary AWS Codebuild is fully managed build service that compiles source code, run tests, and produces software packages that are ready to reploy. To make it easier, we can create it’s infrastructure using terraform. Setup directory structure Before we begin, we can create our own directory structure for the infrastructure. Why this is important? because … Read more

Bash script to run terraform recursively

#!/bin/bash cd prd && ls -d */ declare -a dirs i=1 for d in */ do dirs[i++]=”${d%/}” done echo “There are ${#dirs[@]} dirs in the current path” for((i=1;i<=${#dirs[@]};i++)) do cd “${dirs[i]}” && rm -rf .terraform \ && echo “terraform {” > backend.tf \ && echo “backend \”consul\” {” >> backend.tf \ && echo “}” >> … Read more

Deploy ec2 instance to VPC with terraform

provider “aws” { access_key = “” secret_key = “” region = “ap-southeast-1” } resource “aws_instance” “web-1” { vpc_security_group_ids = [“sg-xxxxxxxx”] subnet_id = “subnet-xxxxxxxx” ami = “ami-xxxxxxxx” availability_zone = “ap-southeast-1a” instance_type = “t2.micro” tags { Name = “test-terraform-1” } }