Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Blog posts : "terraform"

Resolved Terraform Error: POST https api.github.com user repos 401 Requires authentication

I was receiving Error: POST https://api.github.com/user/repos: 401 Requires authentication [] while applying and deploying repository on github.com with Terraform. This error occurs because terraform is not able to authenticate to GitHub.com API and not able to perform the action.

Read more

GitHub repository integration with Terraform Cloud to Deploy and Manage Azure

Streamline your infrastructure as code (IaC) workflows by integrating your GitHub repository with HashiCorp Terraform Cloud (HCP). This powerful combination enables automatic execution of Terraform plans and applies based on changes made to your infrastructure code, ensuring that every update to you…

Read more

Part 4 GitHub Actions deploy azure resources with Terraform backend

In this section, I'm leveraging the azurerm backend to keep the Terraform state (tfstate) file in an Azure Storage Account. This will make sure that the Terraform state is centralized and consistent across different environments and team members. Every time I push changes to my Terraform configurat…

Read more

Part 3 Automating and Planning Azure Resources with Terraform and GitHub Actions

GitHub Actions is a CI/CD tool that automates tasks and workflows within your repository. It lets you to create custom workflows, trigger actions, and keep sensitive information securely. Common use cases include automating testing, deployment, and code quality checks. You can also use GitHub Actio…

Read more

Part 2 Terraform modules using a github.com repository as a source

In this article, I will guide you through the process of configuring a Terraform module hosted on GitHub.com as a source for the use inside Terraform module projects. In my previous blog (Part 1), I demonstrated how to set up a GitHub.com repository and branch using HashiCorp Terraform code.

To S…

Read more

Create GitHub repository and branches using Terraform

In this blog post, I will walk you through using HashiCorp Terraform to create and configure repositories and branches on an existing GitHub account. Before we begin, it's important to note that you should already have an active GitHub account.

To allow Terraform to interact with your GitHub acco…

Read more

Terraform using for loop in attribute value without for_each

In this Terraform example, I explored two approaches to working with map variables. Firstly, I used a for loop to iterate over the key-value pairs in the address_prefixes map, extracting the prefix values and enclosing the loop within square brackets [] to generate list from map.

Alternatively, …

Read more

Terraform for_each for loop list of object without count example

While working with Terraform, I needed to deploy resources without relying on the count meta-argument. My variable was a list of objects, but using count resulted in index numbers being appended to the resource names. To avoid this, I opted to use the for_each argument to iterate over the list of ob…

Read more

Terraform map of object for loop with if condition example

This article I will show the example of Terraform looping map of object variable type and using if condition to filter the map key value. In this demo I provided a map of object inside users variable. Following inside the locals variable, I am using logic for loop over map of objects and if cond…

Read more

HashiCorp HCP Terraform Cloud backend configuration

HCP Terraform Cloud is a managed service presented by HashiCorp that permits users to run Terraform in a cloud-based environment. It provides a protected, scalable, and collaborative platform for infrastructure organizational automation.

HCP Terraform Cloud proposes numerous benefits, including:

Read more

Terraform workspace with example

In the Hashicorp Terraform there is a feature called Terraform workspace that permits you to achieve multiple, isolated infrastructure environments within a single Terraform configuration. A workspace is fundamentally a way to isolate your infrastructure configurations into different environments, s…

Read more

Terraform convert single string to list or set

Below are the few examples of Terraform on to converting single string to array of list or set. This code I was wanted in my one of my Azure automation task. In this example I have defined a variable justice_leage with same default value..

For conversion, In the first scenario I can use split()

Read more

Terraform variable type list with for_each for loop examples

In this article I have explored all the examples on how to use list of strings with for_each for loop in Terraform resource and output block.

Microsoft Azure Terraform toset() for_each map list of string objects resource null_resource output variable block example.png

In this first block of example I have defined  variable named marvel, it's type is list and value has string names of superheroes inside [ ] squa…

Read more

Terraform variable multiple validation advanced blocks example

In my previous article on configuring a Terraform module for an Azure Function App with a private endpoint and a storage account, I shown a section within the application_stack block where I needed to implement function apps stacks. Here in this article I focusing on advanced variable validation for…

Read more

Terraform Azure function app with private endpoint and storage account

In this article I am creating Azure Function App linked to Private Endpoint and Storage Account using Terraform. This terraform configuration file will deploy all these resources within couple of minute.

In this automation Resource Group, User Assigned Identity, Virtual Network, Subnet, Private D…

Read more

Terraform Azure provider passing multiple alias environment and credentials in child module

While working with Terraform modules I wanted to pass on multiple provider aliases with specific credentials and azure subscription details to child module. Ideas was to create resources with assigned privileged users. Non privileged users should not be able to create services in Azure.

In this…

Read more

Terraform Azure provider alias passing credentials and configuration in module resources

In this article I will be configuring alias in AzureRM provider and passing it to child module. Which will allow me to configure/deploy resources with given settings and credentials. In this demo in my Parent module, I will use specific client_id, client_secret, subscription_id, tenant_id to authen…

Read more

Terraform filter map and list object with if condition in for_each loop examples

In terraform there is no actual if else condition block. But still you can use if condition to filter map or list of objects to get the required keys or values. In below example I have scenario where I wanted to create Resource Group in Azure to defined locations only. Incase no data is provided or…

Read more

Terraform variable precedence and priority

This is a informational article on how the variable precedence works in Terraform. This is how the priority is defined for variable when you use it in different ways. In the following diagram, it shows the information of variable priority matrix. Lower the number it has higher the priority and it w…

Read more

Terraform passing different credentials to different subscriptions with provider alias

Terraform passing different credentials to different subscriptions with provider alias.png

While planning and designing Terraform configuration files for Azure deployment, I wanted to deploy resources to different environment in different subscriptions. In the designing code idea was to use different multiple credentials while deploying environments and referencing them with alias.

Read more

20 blog posts

Blog Search

Page Views

12056114

Follow me on Blogarama