• jcnetworking
  • LONDON
AWS
Terraform – AWS

Terraform – AWS

TERRAFORM

We will use terraform to manage cloud infrastructure and deploy in AWS.

  • 2 VPC ( Frontend VPC, Backend VPC)
  • Subnet for both VPC and Routing table
  • Internet gateway -> Frontend VPC
  • Security Group -> Frontend and Backend
  • VPC Peering
  • store tfstate in S3
  • Lockfile located in DynamoDB AWS

After we build, we want to destroy all the related resources. By using “Terraform destroy” you can remove those resources.

Terraform can destory what you creat for 1 specific project.

in Window, you can AWS CLI -> put your credential in AWS config.

Using as below providers for aws

-> to test -> use “terraform init

-> “Terraform Plan” -> to find out what resources, it will be deployed and other information such as subnet, name…etc

terraform {
    required_providers {
        aws = {
         source = "hashicorp/aws"
         version = "~> 3.63"
        }

    }
    required_version = ">= 0.14.9"

}

provider "aws"{
    profile = "default"
    region = "eu-west-1"

}

Say yes to Terraform Apply

Using “output” -> it will return the value after the terraform finish “apply”

Output return: Public ip address and other subnets

output.tf

tfstate file in aws S3 Bucket

tfstate file which is a state of your cloud infrastructure , it included all detail information.

Normally, it will be saved to your local PC.

If we save it is the cloud, more peoples can work with this terraform file.

Saving it in S3 bucket
what is this filed contained

Lock file in DynamoDB

When you are applying the terraform, the file will be locked. In order to prevent numbers of peoples try to apply it at the same time.

RESULT

Type “terraform state list”

it will list what you have deployed via terraform

dsfds

terraform state list
CLI – VPC
CLI – EC2
CLI – SG
AWS – VPC
AWS – EC2
AWS – SG

Now, we login to the machine via aws connect.

we can ping 8.8.8.8

we can ping google.com

curl checkmyip.amazonaws.com -> return the public IP as we expected.

Happy Bunny.

Leave a Reply

Your email address will not be published. Required fields are marked *