Skip to content

Instantly share code, notes, and snippets.

View kunduso's full-sized avatar
🏠
Working from home

sourav kundu kunduso

🏠
Working from home
View GitHub Profile
@kunduso
kunduso / provider.tf
Created November 3, 2020 17:38
Terraform Azure Provider
# Configure the Azure provider
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "2.34.0"
}
}
}
@kunduso
kunduso / azure-pipelines.yaml
Created February 24, 2021 12:43
Installing Terraform in Azure Pipelines using extension
# Install Terraform extension to use this task from:
# https://marketplace.visualstudio.com/items?itemName=ms-devlabs.custom-terraform-tasks&ssr=false#overview
steps:
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-installer-task.TerraformInstaller@0
displayName: 'Install Terraform 0.14.0'
inputs:
terraformVersion: 0.14.0
# Terraform versions: https://releases.hashicorp.com/terraform/
@kunduso
kunduso / azure-pipelines.yaml
Last active February 24, 2021 15:00
Using powershell in azure-pipelines.yaml for terraform validate
- powershell: |
terraform validate -json -no-color
workingDirectory: $(build.sourcesdirectory)
displayName: 'terraform validate'
@kunduso
kunduso / azure-pipelines.yaml
Last active February 24, 2021 22:15
Using powershell in azure-pipelines.yaml for terraform plan
- powershell: |
terraform plan -var region=$(region) -var access_key=$(access_key) -var secret_key=$(secret_key) -out application.tfplan -no-color
workingDirectory: $(build.sourcesdirectory)
displayName: 'terraform plan'
@kunduso
kunduso / azure-pipelines.yaml
Created February 24, 2021 20:30
Using powershell in azure-pipelins.yaml for terraform apply
- powershell: |
terraform apply "application.tfplan" -no-color
workingDirectory: $(build.sourcesdirectory)
displayName: 'terraform apply'
@kunduso
kunduso / azure-pipelines.yaml
Created February 25, 2021 11:15
Using powershell in azure-pipelins.yaml for terraform show
- powershell: |
terraform show -no-color
workingDirectory: $(build.sourcesdirectory)
displayName: 'terraform show'
@kunduso
kunduso / backend.tf
Created March 11, 2021 00:38
This is a representation of the contents of an AWS backend with bucket and dynamoDB details
terraform {
backend "s3" {
bucket = "$(BackendBucketName)" # the name of the S3 bucket that was created
encrypt = true
key = "$(PathToTFStateFile)" # the path to the terraform.tfstate file stored inside the bucket
region = "$(BucketRegion)" # the location of the bucket
dynamodb_table = "$(BackendLockTableName)" # the name of the table to store the lock
}
}
@kunduso
kunduso / backend-policy.json
Last active April 2, 2021 21:29
This is an AWS IAM policy to provide restricted access to Terraform to communicate with the backend resources -AWS S3 bucket and dynamoDB table
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"dynamodb:PutItem",
"dynamodb:DeleteItem",
"dynamodb:GetItem"
@kunduso
kunduso / backend.tf
Created March 24, 2021 10:31
This is a representation of the contents of an Azure backend with resource group, storage account name, container name, and storage account access key details
terraform {
backend "azurerm" {
resource_group_name = "$(ResourceGroupToStoreTerraformBackendResources)"
storage_account_name = "$(UniqueStorageAccountName)"
container_name = "$(StorageContainerName)"
key = "terraform.tfstate"
access_key = "$(StorageAccountAccessKey)"
}
}
@kunduso
kunduso / azure-pipelines.yaml
Last active March 25, 2021 10:57
Terraform init command using powershell in Azure Pipelines
- powershell: |
terraform init -backend-config="access_key=$(storage_access_key)" -no-color
workingDirectory: $(build.sourcesdirectory)
displayName: 'terraform init'
# where $(storage_access_key) is a secret variable stored in the Azure pipeline
# variable or a Library variable group. The value of the variable is the storage
# access key to the storage account where the terraform remote state file is stored