← azuredeploy

Switching to terragrunt

7a4361d3a7077f976ab81fb3e1a79dab208cb7ba · ovidiucs · Apr 20, 2024 18:17

−348 · 8 files changed

  • terraform/README.md +0 −46
  • terraform/main.tf +0 −40
  • terraform/modules/terraforn-azurerm-aks/main.tf +0 −36
  • terraform/modules/vm/vm.tf +0 −76
  • terraform/outputs.tf +0 −9
  • terraform/terraform.tfvars +0 −13
  • terraform/variables.tf +0 −120
  • terraform/versions.tf +0 −8
diff --git a/terraform/README.md b/terraform/README.md
deleted file mode 100644
index e7f8d27..0000000
--- a/terraform/README.md
+++ /dev/null
@@ -1,46 +0,0 @@
-### Overall Directory layout for the terraform deployments
-```.
-├── main.tf                 # Entry point of the Terraform configuration, often contains provider configuration
-├── variables.tf            # Defines variables used across the project
-├── outputs.tf              # Defines outputs from your Terraform configuration
-├── terraform.tfvars        # Contains values for the defined variables
-├── backend.tf              # (Optional) Contains backend configuration for state management
-├── versions.tf             # Sets the Terraform version and provider requirements
-├── README.md               # Project documentation for maintainers and users
-└── modules/
-    ├── network/            # Network module, e.g., VNets, subnets, NSGs
-    │   ├── main.tf
-    │   ├── variables.tf
-    │   ├── outputs.tf
-    │   └── ...
-    ├── compute/            # Compute module, e.g., VMs, scale sets
-    │   ├── main.tf
-    │   ├── variables.tf
-    │   ├── outputs.tf
-    │   └── ...
-    └── storage/            # Storage module, e.g., blob storage, disk
-        ├── main.tf
-        ├── variables.tf
-        ├── outputs.tf
-        └── ...
-```
-File and Directory Roles
-
-**main.tf**: This is often the entry point for Terraform configurations. In the root directory, it might contain provider configurations and module invocations. Within modules, it contains the main set of resources that module manages.
-
-**variables.tf:** Defines variables for the module or root configurations, making your configurations flexible and reusable.
-
-**outputs.tf:** Defines output values that you can use to retrieve information about the resources, such as IDs or endpoints, and can be used by other configurations or modules.
-
-**terraform.tfvars:** Contains actual values for the declared variables. Sensitive values should not be committed to version control, so consider using environment variables or encrypted secrets management for those.
-
-**backend.tf:** Optionally specifies backend configuration where Terraform state information is stored. This is crucial for team environments or when using Terraform in automation (CI/CD pipelines).
-
-**versions.tf:** Specifies required versions for Terraform and providers, ensuring consistent behavior across different environments and team members.
-
-**README.md:** Provides documentation for your project, explaining its purpose, how to use it, and any prerequisites or configuration steps.
-
-**Modules Directory:** Contains subdirectories for each modularized component of your infrastructure, like networking or compute resources. This allows you to encapsulate and reuse configurations.
-
-
-Define variables
diff --git a/terraform/main.tf b/terraform/main.tf
deleted file mode 100644
index 1ea0c2a..0000000
--- a/terraform/main.tf
+++ /dev/null
@@ -1,40 +0,0 @@
-provider "azurerm" {
-  features {}
-}
-
-resource "azurerm_resource_group" "az-rg-lbl" {
-  name     = var.resource_group_name
-  location = var.location
-}
-
-module "aks" {
-  source  = "github.com/Azure/terraform-azurerm-aks"
-
-  resource_group_name = azurerm_resource_group.az-rg-lbl.name
-  location            = azurerm_resource_group.az-rg-lbl.location
-  cluster_name        = var.cluster_name
-  kubernetes_version  = var.kubernetes_version
-  cluster_log_analytics_workspace_name = var.cluster_log_analytics_workspace_name
-  prefix          = var.dns_prefix
-  rbac_aad = false
-  
-  node_pools = {
-    node_pool_a = {
-      name                = var.default_node_pool_name
-      node_count          = var.node_count
-      vm_size             = var.vm_size
-    }
-  }
-
-  admin_username = var.admin_username
-  public_ssh_key = file(var.ssh_public_key)
-
-  tags = var.tags
-
-  depends_on = [azurerm_resource_group.az-rg-lbl]
-}
-
-module "vm" {
-  source = "./modules/vm"
-  # Add the required variables for the VM module
-}
diff --git a/terraform/modules/terraforn-azurerm-aks/main.tf b/terraform/modules/terraforn-azurerm-aks/main.tf
deleted file mode 100644
index 738e939..0000000
--- a/terraform/modules/terraforn-azurerm-aks/main.tf
+++ /dev/null
@@ -1,36 +0,0 @@
-provider "azurerm" {
-  features {}
-  version = "~> 2.0"
-}
-
-module "aks" {
-  source  = "https://github.com/Azure/terraform-azurerm-aks?ref=main"
-  version = "1.0.0" # Use the appropriate version
-
-  resource_group_name = var.resource_group_name
-  location            = var.location
-  cluster_name        = var.cluster_name
-  kubernetes_version  = var.kubernetes_version
-  dns_prefix          = var.dns_prefix
-
-  default_node_pool {
-    name                = var.default_node_pool_name
-    node_count          = var.node_count
-    vm_size             = var.vm_size
-  }
-
-  linux_profile {
-    admin_username = var.admin_username
-    ssh_key {
-      key_data = file(var.ssh_public_key)
-    }
-  }
-
-  service_principal {
-    client_id     = var.client_id
-    client_secret = var.client_secret
-  }
-
-  tags = var.tags
-}
-
diff --git a/terraform/modules/vm/vm.tf b/terraform/modules/vm/vm.tf
deleted file mode 100644
index c983a17..0000000
--- a/terraform/modules/vm/vm.tf
+++ /dev/null
@@ -1,76 +0,0 @@
-provider "azurerm" {
-  features {}
-}
-
-resource "azurerm_resource_group" "example" {
-  name     = "example-resources"
-  location = "East US"
-}
-
-resource "azurerm_virtual_network" "example" {
-  name                = "example-network"
-  address_space       = ["10.0.0.0/16"]
-  location            = azurerm_resource_group.example.location
-  resource_group_name = azurerm_resource_group.example.name
-}
-
-resource "azurerm_subnet" "example" {
-  name                 = "example-subnet"
-  resource_group_name  = azurerm_resource_group.example.name
-  virtual_network_name = azurerm_virtual_network.example.name
-  address_prefixes     = ["10.0.2.0/24"]
-}
-
-resource "azurerm_public_ip" "example" {
-  name                = "example-publicip"
-  location            = azurerm_resource_group.example.location
-  resource_group_name = azurerm_resource_group.example.name
-  allocation_method   = "Dynamic"
-}
-
-resource "azurerm_network_security_group" "example" {
-  name                = "example-nsg"
-  location            = azurerm_resource_group.example.location
-  resource_group_name = azurerm_resource_group.example.name
-}
-
-resource "azurerm_network_interface" "example" {
-  name                = "example-nic"
-  location            = azurerm_resource_group.example.location
-  resource_group_name = azurerm_resource_group.example.name
-
-  ip_configuration {
-    name                          = "internal"
-    subnet_id                     = azurerm_subnet.example.id
-    private_ip_address_allocation = "Dynamic"
-    public_ip_address_id          = azurerm_public_ip.example.id
-  }
-}
-
-resource "azurerm_linux_virtual_machine" "example" {
-  name                = "example-vm"
-  resource_group_name = azurerm_resource_group.example.name
-  location            = azurerm_resource_group.example.location
-  size                = "Standard_F2"
-  admin_username      = "adminuser"
-  network_interface_ids = [
-    azurerm_network_interface.example.id,
-  ]
-
-  os_disk {
-    caching              = "ReadWrite"
-    storage_account_type = "Standard_LRS"
-  }
-
-  source_image_reference {
-    publisher = "Canonical"
-    offer     = "UbuntuServer"
-    sku       = "18.04-LTS"
-    version   = "latest"
-  }
-
-  admin_ssh_key {
-    username   = "adminuser"
-    public_key = file("~/.ssh/id_rsa.pub")
-  }
-}
diff --git a/terraform/outputs.tf b/terraform/outputs.tf
deleted file mode 100644
index dbf3e92..0000000
--- a/terraform/outputs.tf
+++ /dev/null
@@ -1,9 +0,0 @@
-output "aks_cluster_name" {
-  description = "The name of the AKS cluster"
-  value       = module.aks.aks_name
-}
-
-output "aks_cluster_id" {
-  description = "The ID of the AKS cluster"
-  value       = module.aks.aks_id
-}
diff --git a/terraform/terraform.tfvars b/terraform/terraform.tfvars
deleted file mode 100644
index a9a367b..0000000
--- a/terraform/terraform.tfvars
+++ /dev/null
@@ -1,13 +0,0 @@
-resource_group_name = "AZ-AKS-RG"
-cluster_name        = "AZ-AKS001"
-kubernetes_version  = "1.29.0"
-node_count          = 3
-agents_max_count    = 5
-agents_min_count    = 1
-vm_size             = "Standard_B1s"
-client_id           = ""
-client_secret       = ""
-ssh_public_key      = "~/.ssh/azure_test1.pub"
-location            = "westeurope"
-cluster_log_analytics_workspace_name = "AZ-LOG-AN-AKS-A001"
-dns_prefix              = "aks"
diff --git a/terraform/variables.tf b/terraform/variables.tf
deleted file mode 100644
index f69de52..0000000
--- a/terraform/variables.tf
+++ /dev/null
@@ -1,120 +0,0 @@
-variable "azure_region" {
-  description = "azure region"
-  type        = string
-  default     = "eu-west-2"
-}
-
-variable "name" {
-  description = "name"
-  type        = string
-  default     = "app-failover-and-traffic"
-}
-
-variable "admin_username" {
-  description = "The name of the project"
-  type        = string
-  default     = "admin"
-}
-
-variable "ssh_public_key" {
-  description = "The path to the SSH Key File"
-  type        = string
-}
-
-variable "project" {
-  description = "The name of the project"
-  type        = string
-  default     = "automation-project-one"
-}
-
-variable "client" {
-  description = "The client for the project"
-  type        = string
-  default     = "public"
-}
-
-variable "owner" {
-  description = "The owner of the project"
-  type        = string
-  default     = "Ovidiu"
-}
-
-variable "environment" {
-  description = "The project environment"
-  type        = string
-  default     = "dev"
-}
-
-variable "resource_group_name" {
-  description = "The name of the resource group"
-  type        = string
-}
-
-variable "cluster_name" {
-  description = "The name of the AKS cluster"
-  type        = string
-}
-
-variable "kubernetes_version" {
-  description = "The Kubernetes version for the AKS cluster"
-  type        = string
-}
-
-variable "node_count" {
-  description = "The number of nodes in the default node pool"
-  type        = number
-}
-
-variable "agents_max_count" {
-  description = "The maximum number of nodes in the default node pool"
-  type        = number
-}
-
-variable "agents_min_count" {
-  description = "The minimum number of nodes in the default node pool"
-  type        = number
-}
-
-variable "vm_size" {
-  description = "The size of the virtual machines in the default node pool"
-  type        = string
-}
-
-variable "client_id" {
-  description = "The client ID of the service principal"
-  type        = string
-}
-
-variable "client_secret" {
-  description = "The client secret of the service principal"
-  type        = string
-}
-
-variable "location" {
-  description = "The location where the resources will be created."
-  type        = string
-}
-
-variable "default_node_pool_name" {
-  description = "The name of the default node pool."
-  type        = string
-  default     = "nodepool1"
-}
-
-variable "tags" {
-  description = "A map of tags to add to all resources."
-  type        = map(string)
-  default     = {}
-}
-
-variable "cluster_log_analytics_workspace_name" {
-     description = "The name of the existing Log Analytics workspace to use for AKS monitoring."
-     type        = string
-     default     = null
-}
-
-variable "dns_prefix" {
-     description = "The prefix to use for naming resources."
-     type        = string
-     default     = null
-}
diff --git a/terraform/versions.tf b/terraform/versions.tf
deleted file mode 100644
index 8972faa..0000000
--- a/terraform/versions.tf
+++ /dev/null
@@ -1,8 +0,0 @@
-terraform {
-  required_providers {
-    azurerm = {
-      source  = "hashicorp/azurerm"
-      version = "~> 3.0"
-    }
-  }
-}