TerraWeek Day 6: Terraform Providers

TerraWeek Day 6: Terraform Providers

Introduction

In this blog, we will explore the concept of Terraform providers, compare major cloud providers such as AWS, Azure, and Google Cloud, delve into provider configuration and authentication, and provide insights on working with each provider.

Terraform Providers

Terraform providers are plugins that enable Terraform to interact with various cloud platforms, infrastructure services, and APIs. Providers are responsible for understanding API interactions and exposing resources that can be managed using Terraform. Some popular providers include AWS, Azure, Google Cloud, and others.

To use a provider, you need to declare it in your Terraform configuration file (usually a .tf file). Here's an example of the AWS provider:

provider "aws" {
  region = "ap-south-1"
}        

Comparing Providers

Terraform providers are plugins that allow Terraform to interact with various cloud platforms and infrastructure services. They are responsible for understanding API interactions and exposing resources to be managed by Terraform. Some popular Terraform cloud providers include:

AWS: Terraform AWS provider

Azure: Terraform Azure Provider

Google Cloud: Terraform Google Cloud Provider

Each provider has its own set of supported resources and features. To compare them, visit the respective provider's documentation and explore the available resources and data sources.

Provider Configuration and Authentication

Each provider has its own set of configuration options, which are used to authenticate and interact with the respective cloud platform or service. These options can include API keys, access tokens, or other credentials required for authentication.

For example, the AWS provider necessitates an access key and secret key for authentication. You can provide these credentials through various means, including environment variables, a shared credentials file, or directly within the provider configuration block:

provider "aws" {
  region     = "ap-south-1"
  access_key = "your_access_key"
  secret_key = "your_secret_key"
}        

Use environment variables or shared credentials files to avoid exposing sensitive information in your Terraform configuration files.

Working with AWS Provider

The AWS provider allows you to manage resources in your AWS account. declare the AWS provider in your Terraform configuration file:

provider "aws" {
  region = "ap-south-1"
}        

create an Amazon S3 bucket using the AWS provider:

resource "aws_s3_bucket" "mera_balati" {
  bucket = "my-exp_2023-bucket"
  acl    = "private"
}        

Run terraform init to initialize your Terraform working directory and download the required provider plugins. Then, run terraform plan, terraform apply to generate a plan of action and then create the S3 bucket.

Working with Azure Provider

The Azure provider allows you to manage resources in your Azure account. To get started, declare the Azure provider in your Terraform configuration file:

provider "azurerm" {
  features {}
}        

Let's create a resource group utilizing the Azure provider.

resource "azurerm_resource_group" "example" {
  name     = "my-resource-group"
  location = "West US"
}        

After defining resources run below commands:

terraform init
terraform plan
terraform apply        

Working with Google Cloud Provider

The Google Cloud provider allows you to manage resources in your Google Cloud account. To get started, declare the Google Cloud provider in your Terraform configuration file:

provider "google" {
  project = "my-terra-project"
  region  = "us-central1"
  zone    = "us-central1-a"
}        

Let's create a Google Cloud Storage bucket using the Google Cloud provider:

resource "google_storage_bucket" "terraweek-bucket" {
  name     = "my-terra-bucket"
  location = "us-central1"
  storage_class = "STANDARD"
}        

To defining the resources run below commands to create the storage bucket.:

terraform init
terraform plan
terraform apply        

Happy Learning!!







Sahdev Grover

Data Governance | Snowflake | Microsoft PowerApps | Microsoft Power Automate | Microsoft PowerBI | Alation | Immuta | Airflow | SQL | Python | AWS | Terraform | Docker

1 年

Hey Aashish R. , Glad to hear that you have started working on terraform; I would like to share with you everything you need to know about the terraform. You can access my GitHub repo and all the resources I have covered in terraform from basic to advanced and I hope that would help you to prep for the certification journey as well in your enhancing the skills. Link: https://github.com/sahdevgrover

要查看或添加评论,请登录

Aashish R.的更多文章

  • Serverless on AWS

    Serverless on AWS

    Are you excited to know about serverless architecture!! You can build and run applications without thinking about…

  • TerraWeek Day 7 - Advanced Terraform Topics

    TerraWeek Day 7 - Advanced Terraform Topics

    Welcome to the advanced TerraWeek challenge! In this phase, we will dive into advanced topics that will enhance your…

  • TerraWeek Day 5

    TerraWeek Day 5

    Task 1: What are modules in Terraform and why do we need modules in Terraform? You already write modules Even when you…

  • Terraweek Day 4 Knowledge about Terraform state, Local and Remote configurations

    Terraweek Day 4 Knowledge about Terraform state, Local and Remote configurations

    Task 1:The importance of Terraform state in managing infrastructure The primary purpose of Terraform state is to store…

  • TerraWeek Day 3

    TerraWeek Day 3

    Task 1:Create a Terraform configuration file to define a resource of AWS EC2 instance, Azure storage account, Google…

    1 条评论
  • HashiCorp Configuration language(HCL)

    HashiCorp Configuration language(HCL)

    #TerraWeekChallenge DAY 2 Terraform Syntax , Block parameter and arguments ,variable , data types , expressions , .tf…

  • Deployment of a Microservices Application on K8s- Do MongoDB App Deployment

    Deployment of a Microservices Application on K8s- Do MongoDB App Deployment

    Kubernetes, also known as K8s, is an open-source system for automating deployment, scaling, and management of…

  • How to Install terraform on Ubuntu server.

    How to Install terraform on Ubuntu server.

    What is Terraform? HashiCorp Terraform is an infrastructure as code tool that lets you define both cloud and on-prem…

    1 条评论
  • Deploying Reddit Copy on Kubernetes Cluster using Ingress.

    Deploying Reddit Copy on Kubernetes Cluster using Ingress.

    Prerequisites: ? EC2 (AMI- Ubuntu, Type- t2.medium) ? Docker ? Minikube ? Kubectl Follow below steps for install all…

    5 条评论

社区洞察

其他会员也浏览了