8000 GitHub - ishuar/aws-terraform
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ishuar/aws-terraform

Repository files navigation

Introduction

  1. Terraform

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.
Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied.
The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc.

  1. Amazon Web Services

Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud platform, offering over 200 fully featured services from data centers globally. Millions of customers—including the fastest-growing startups, largest enterprises, and leading government agencies—are using AWS to lower costs, become more agile, and innovate faster.

AWS-terraform project

  • This project demonstrates the core power of cloud computing and infrastructure as code , within few minutes and with just few lines you could set up a fully enterprise grade IT infra to host your monolithic or microservices applications.

  • With this code you could set up a cluster of 2 EC2 instances hosting a nginx docker container as webserver in differnet Availability Zone in single region with one Application Load Balancer in front, distributing the backend traffic with required networking setup. With making sure that our state files are also get backed up on AWS S3 buckets. "Sounds Fun isn't it !!"

Prerequisite

  1. Terraform V-1.0.1 Download URL
  2. AWS Account with Admin access Console

Installation Process

  1. Creation of Backend bucket

Change directory to remote-state and perform below tasks.

cd remote-state
terraform init
terraform plan
terraform apply 
  1. Terraform Init

To work on our main config move out of remote-state dir. For initiating the terraform to download the plugins as per your provider in this case AWS , execute below command from the directory having main.tf and other .tf* files.

cd ..
terraform init
  1. Variables

Prepare your variable file terraform.tfvars or *.tfvars accordingly as per the variables defined in the main.tf file.

  1. Terraform Plan

For rendering objects created by the terraform and as a best practice always do a terraform plan before applying the config.

  1. Terraform apply

Use command terraform apply to apply the config.

terraform apply
  1. Terraform state

To view the list of all objects created by Terraform use terraform state list command.

terraform state list

Uninstall/Destroy Objects

  • Use terraform destroy command for destroying all objects mentioned in config file. If we want to remove specific object then we can use terraform destroy -target aws_<resource_name>.<name_mentioned_maintf>.However it is not the best practice, always try to keep your config file updated as per the infra required.
terraform destroy 
terraform destroy -target aws_vpc.myapp_vpc ## will delete vpc only

Extra Information

[x] Refer to Terraform-AWS documentation for extra custom configs.
[x] As for backend terraform configuration bucket should be already existing in our infra. We have created a dedicated directory remote-state with config for bucket provisioning.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0