Posts

Showing posts from 2023

Introduction to IaC: Deploying Data infrastructure to Azure using Terraform (Part 4 - Using Github)

Image
  In Part 1 , we explain the basics and prerrequisites to work with Terraform. In Part 2 , we created our first Azure resource. In Part 3 , we deployed our fist solution (Azure SQL database) using multiple resources. On this post, we will integrate Terraform to use the Version Control System Git, implemented using GitHub . Version control is outside the scope of this post, but if you want to learn more about it, you can check these excellent resources: Introduction to version control with Git Introduction to GitHub Automate your workflow with GitHub Actions   Manage the lifecycle of your projects on GitHub   OK, once you have a good idea of what VCS and Github are about, we can integrate it into our Terraform solution and use it as a external repository for our IaC. For simplicity, we will use the same folder and code from the previous post : cd C: \T erraform \T erraform_AZ_example code . Make sure the .gitignore file is in place, since we will source it and is a good practice to in

Introduction to IaC: Deploying Data infrastructure to Azure using Terraform (Part 3 - Azure SQL Database)

Image
In Part 1 , we explain the basics and prerrequisites to work with Terraform. In Part 2 , we created our first Azure resource. On this post we will create an Azure SQL Database and configure it so we can access it right away. Example 2: Deploy and configure an Azure SQL database To create an Azure SQL database, we need at least the following: Resource group (we already have it from the previous example) Azure SQL Server Azure SQL database At least one firewall rule We can obtain code snippets on each resource from the Terraform provider documentation we checked on the previous example: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs We proceed to add each component on the main.tf file (do not delete the previous code we have there) At the end we should have something like this (just check resource names and parameters to match what you want.) terraform { required_providers { azurerm = { source = "hashicorp/azurerm" version = "3.

Introduction to IaC: Deploying Data infrastructure to Azure using Terraform (Part 2 - our first Azure resource)

Image
Continuing our Part 1 , we already set up our environment, we can now setup our very first example (do not worry if is too simple at this point, but this is just to understand how it works). Example 1: Deploy an Azure Resource Group I think the Azure Resource Group is the most basic Azure resource, so we will verify our setup is ok by deploying one. First, create your project folder on your local machine, in my case I am using C:\Terraform\Terraform_AZ_example but you can use any path you want. Then, open that folder in VSCode: cd C:\Terraform\Terraform_AZ_example code . Or use the GUI to open the folder:   Once opened, I like, as a best practice to add this .gitignore file even when you work locally, so sensitive information and Terraform state is not uploaded if you decide source to GitHub: # Local .terraform directories **/. terraform /* # .tfstate files *. tfstate *. tfstate .* # Crash log files crash . log crash .*. log # Exclude all .tfvars files, which are likely

Introduction to IaC: Deploying Data infrastructure to Azure using Terraform (Part 1 - Intro and prerequisites)

Image
Introduction One integral part of modern Continuous Integration and Continuous Development (CI/CD) pipelines is the ability to create the underlying infrastructure as part of the pipeline in a consistent and repeatable manner. Infrastructure as Code (IaC) offers this capability, allowing us to automate and deploy multi-cloud infrastructure as definition scripts. This approach helps us to reduce time invested in provisioning the infrastructure, as well as reducing human errors or misconfigurations.  The infrastructure can also be redeployed to other environments knowing that the configuration will be the same each time. Although Azure offers ARM templates and AWS offers CloudFormation, these are just for its respective cloud provider. Which option do we have if we need an enterprise-grade solution that supports multi-cloud environments and can integrate with our CI/CD pipelines? Terraform is a declarative, open source IaC tool that can deploy to multiple cloud providers and offers a gr