0% found this document useful (0 votes)
3 views16 pages

Terraform_tasks

The document outlines a step-by-step guide for implementing Terraform tasks using GitHub Codespaces, including setting up AWS credentials and configuring various AWS resources. Key tasks include creating a Virtual Private Cloud (VPC), subnets, an Internet Gateway, EC2 instances, load balancers, and IAM roles, along with commands for formatting, validating, planning, and applying changes. Each section provides specific Terraform configuration file commands and processes to ensure proper setup and deployment of resources in AWS.

Uploaded by

vinsparky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views16 pages

Terraform_tasks

The document outlines a step-by-step guide for implementing Terraform tasks using GitHub Codespaces, including setting up AWS credentials and configuring various AWS resources. Key tasks include creating a Virtual Private Cloud (VPC), subnets, an Internet Gateway, EC2 instances, load balancers, and IAM roles, along with commands for formatting, validating, planning, and applying changes. Each section provides specific Terraform configuration file commands and processes to ensure proper setup and deployment of resources in AWS.

Uploaded by

vinsparky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Terraform Tasks

What I need before


I am using github codesapce as a server to implement terraform tasks.

In this codespace I installed terraform and aws cli.

setup my aws account with this codesapce using aws configure.

It asks your aws account secret key and access key.

Now all set!...

1.Configure aws provider


sudo nano provider.tf

terraform init (to initialize Terraform and download the AWS provider plugin.)

2.Create Virtual Private Cloud(VPC)


sudo nano vpc.tf
terraform fmt (Formats all .tf files in the current directory)

terraform validate (Checks syntax, structure, and logical issues)

terraform plan (Simulates changes and shows what will be created/updated)

terraform apply (Applies changes and prompts for confirmation)

output in aws console:

2.Create Public and Private Subnets


sudo nano subnets.tf

terraform fmt

terraform validate
terraform plan

terraform apply

3.Create Internet Gateway


sudo nano igw.tf

terraform fmt

terraform validate

terraform plan

terraform apply

4.Create public route table and attach it with internet gateway,


public subnet
sudo nano publicroutetable.tf
terraform fmt

terraform validate

terraform plan

terraform apply

5.Create EC2 instance


sudo nano EC2.tf

terraform fmt
terraform validate

terraform plan

terraform apply

6.Create ApplicationLoadBalancer, TargetGroup, Listener


sudo nano loadbalancer.tf

In this you have to configure your pem file instead of my keypair Instance1.

terraform fmt

terraform validate
terraform plan

terraform apply

7.Configure AutoScaling
sudo nano autoscaling.tf
terraform fmt

terraform validate

terraform plan

terraform apply

8.Create SecurityGroupt to allow http


sudo nano securitygroup.tf
terraform fmt

terraform validate

terraform plan

terraform apply

9.Create NAT Gateway and Elastic ip


sudo nano natgateway.tf
terraform fmt

terraform validate

terraform plan

terraform apply

10.Create PrivateRouteTable and associate with private subnet


sudo nano privateroutetable.tf
terraform fmt

terraform validate

terraform plan

terraform apply

11.Create IAM user and attach adminstrator ploicy


sudo nano iamuser.tf
terraform fmt

terraform validate

terraform plan

terraform apply
12.Create IAM Role and attach it to instance
sudo nano iamrole.tf

sudo nano EC2.tf

terraform fmt

terraform validate

terraform plan
terraform apply

13.Create S3 Bucket and store terraform state file in this bucket.


sudo nano s3bucket.tf

terraform fmt
terraform validate

terraform plan

terraform apply

14.Create cloudwatch alarm for EC2 and sebd a notification to


your email
sudo nano cloudwatchalarm.tf
terraform fmt

terraform validate

terraform plan

terraform apply

You might also like