Skip to content

This repository contains Terraform configuration files to set up Azure infrastructure, including a resource group, virtual network, subnets, public IP, NAT gateway, and associations.

License

Notifications You must be signed in to change notification settings

RimDammak/azure-infrastructure-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📖 README.md

🌐 Azure Infrastructure Setup

Welcome to the Azure Infrastructure Setup repository! This repository contains Terraform configurations to create and manage an Azure environment with a resource group, virtual network, subnets, public IP, NAT gateway, and necessary associations.

🚀 Prerequisites

Before you begin, ensure you have the following installed:

Quick start

Step 1: Create terraform.tfvars file Create a file named terraform.tfvars and add the following content:

name = "resource-group-name"

Step 2: Apply the Terraform Configuration Run the following command to apply your Terraform configuration using the variables defined in terraform.tfvars:

terraform apply -var-file="terraform.tfvars"

🛠 Configuration

Resource Group

Creates an Azure resource group.

resource "azurerm_resource_group" "this" {
  location = var.location
  name     = "${var.name}-Group"
}

provider "azurerm" {
  features {}
}

Virtual Network

Creates a virtual network in Azure.

resource "azurerm_virtual_network" "VN" {
  name                = var.name
  address_space       = [var.address_space]
  location            = azurerm_resource_group.this.location
  resource_group_name = azurerm_resource_group.this.name
}

Subnets

Creates public and private subnets.

resource "azurerm_subnet" "public-subnet" {
  name                 = "${var.name}-public-subnet"
  resource_group_name  = azurerm_resource_group.this.name
  virtual_network_name = azurerm_virtual_network.VN.name
  address_prefixes     = [cidrsubnet(var.address_space, 8, 1)]
}

resource "azurerm_subnet" "private-subnet" {
  name                 = "${var.name}-private-subnet"
  resource_group_name  = azurerm_resource_group.this.name
  virtual_network_name = azurerm_virtual_network.VN.name
  address_prefixes     = [cidrsubnet(var.address_space, 8, 10)]
}

Public IP

Creates a static public IP address.

resource "azurerm_public_ip" "public-IP" {
  name                = "${var.name}-Public-IP"
  location            = azurerm_resource_group.this.location
  resource_group_name = azurerm_resource_group.this.name
  allocation_method   = "Static"
  sku                 = "Standard"
  zones               = [1]
}

NAT Gateway

Creates a NAT gateway.

resource "azurerm_nat_gateway" "natgateway" {
  name                    = "${var.name}-NAT"
  location                = azurerm_resource_group.this.location
  resource_group_name     = azurerm_resource_group.this.name
  sku_name                = "Standard"
  idle_timeout_in_minutes = 10
  zones                   = [1]
}

Associations

Associates the NAT gateway with the public IP and private subnet.

resource "azurerm_nat_gateway_public_ip_association" "this" {
  nat_gateway_id       = azurerm_nat_gateway.natgateway.id
  public_ip_address_id = azurerm_public_ip.public-IP.id
}

resource "azurerm_subnet_nat_gateway_association" "this" {
  subnet_id       = azurerm_subnet.private-subnet.id
  nat_gateway_id  = azurerm_nat_gateway.natgateway.id
}

📦 Usage

  1. Clone the repository:

    git clone https://github.com/yourusername/azure-infrastructure-setup.git
    cd azure-infrastructure-setup
  2. Initialize Terraform:

    terraform init
  3. Apply the configuration:

    terraform apply

📚 Resources

For more details, check the Terraform documentation.

🤝 Contributing

Contributions are welcome! Please open an issue or submit a pull request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

This repository contains Terraform configuration files to set up Azure infrastructure, including a resource group, virtual network, subnets, public IP, NAT gateway, and associations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages