Followers

Terraform -AWS Installation

 

Install awscli for Linux

  1. curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
  2. unzip awscliv2.zip
  3. sudo ./aws/install
  4. aws --version

Aws Configuration (rprofile is the name of the profile)

  1. aws configure 
  2. aws iam list-users 

Install Terraform on ubuntu

  1. curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
  2. sudo apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
  3. sudo apt install terraform

Terraform Basics

  1. First Terraform file
  2. What is statefile and its importance
  3. Different ways to give access to tf
  4. Terraform Variables and its usages
  5. Terraform input variables
  6. Terraform output variables

terraform init

terraform plan

terraform apply

terraform destroy

Terraform State file

.tfstate

Example1 - Create an empty terraform file(.tf)

  • Create an empty directory called( say 01)
  • Goto 01 directory (cd 01)
  • Create an empty file called hello.tf
  • run command terraform init
  • run command terraform plan
  • run command terraform apply it should create terraform.tfstate file

Example2 - Create a provider aws

  • Add following code
    provider "aws"{
                 }
    
  • run command terraform init command
  • it will create .terraform directory for aws plugins

Authentication

The AWS provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below:

  1. Static credentials
  2. Environment variables
  3. Shared credentials/configuration file
  4. CodeBuild, ECS, and EKS Roles
  5. EC2 Instance Metadata Service (IMDS and IMDSv2)

Static credentials

Static credentials can be provided by adding an access_key and secret_key in-line in the AWS provider block:

Usage:

provider "aws" {
  region     = "us-west-2"
  access_key = "my-access-key"
  secret_key = "my-secret-key"
}

Example (To create an EC2 instance with a key)

provider "aws" {
  region     = "ap-south-1"
  access_key = "AKIAZYCCNWPBYU7NQN7M"
  secret_key = "BeO52msn/TiT3p1YrE1xkpnMsHokSEzLiCR0ZL/u"
}
resource "aws_instance" "example" {
  ami           = "ami-041db4a969fe3eb68"
  instance_type = "t2.micro"
  key_name = "devops"
  tags = {
    Name = "HelloWorld"
  }
}

COMMENTS

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
static_page
DevOpsWorld: Terraform -AWS Installation
Terraform -AWS Installation
DevOpsWorld
https://www.devopsworld.co.in/p/terraform-aws-installation.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/p/terraform-aws-installation.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content