Skip to content

Latest commit

 

History

History
143 lines (117 loc) · 7.24 KB

README.md

File metadata and controls

143 lines (117 loc) · 7.24 KB

Terraform Azure Modules Folder

All the module calls made from this folder from dev.tf file.

  • This folder contains following files
    • dev.tf (modules file )
    • backend.tf ( contains backend configuration of the terraform, which contains terraform state files).
    • outputs.tf ( output's of the resource attributes after terraform apply)
    • version.tf ( contains terraform version and cloud provider version)
    • variables.tf (all the variable which required by the terraform modules.)

What is a module?

A Terraform Module is a canonical, reusable, best-practices definition for how to run a single piece of infrastructure, such as a database or server cluster. Each Module is written using a combination of Terraform and scripts (mostly bash) and include automated tests, documentation, and examples.

  • Every module has:
    • Input variables: to accept values from the calling module.
    • Output values: to return results to the calling module, which it can then use to populate arguments elsewhere.
    • Resources: to define one or more infrastructure objects that the module will manage.
    • Source: A source can be any local folder path or remote module located in source control systems like git.

AKS cluster module example Usage.

Usage: The following module call will create AKS cluster and cluster node pool resources. Resources will be configured by using the following input variables on this module.

# Azure Kubernetes service module.
module "aks" {
  source              = "../modules/aks"
  name                = local.prefix
  environment         = var.environment
  kubernetes_version  = var.kubernetes_version
  resource_group_name = module.iam.resource_group_name
  location            = module.iam.location
  private_subnet      = module.vnet.private_subnets
  user_assigned_id    = module.iam.user_id

  tags = merge(local.tags, { "resource_group" = module.iam.resource_group_name })
}

Vnet Module Example usage

Usage: The following module call will create Azure virtual network(Vnet) and Subnet resources. Resources will be configured using the following input variables on this module.

# Azure Virtuval network module
module "vnet" {
  source                    = "../modules/vnet"
  name                      = local.prefix
  environment               = var.environment
  resource_group_name       = module.iam.resource_group_name
  location                  = module.iam.location
  public_subnet_prefixes    = var.public_subnet_prefixes
  private_subnet_prefixes   = var.private_subnet_prefixes
  private_service_endpoints = var.private_service_endpoints
  policy_id                 = module.storage.policy_id

  tags = merge(local.tags, { "resource_group" = module.iam.resource_group_name })
}

IAM module example usage

Usage: The following module call will create Identity resources. Resources will be configured using the following input variables on this modules.

# Azure Identities module
module "iam" {
  source      = "../modules/iam"
  name        = local.prefix
  environment = var.environment
  location    = var.region
  tags        = local.tags
}

storage module example usage

Usage: The following module call will create Azure cloud Storage Account. Resources will be configured using following input variables on this module.

# Azure Storage Account module
module "storage" {
  source              = "../modules/storage"
  name                = local.prefix
  environment         = var.environment
  resource_group_name = module.iam.resource_group_name
  location            = module.iam.location

  tags = merge(local.tags, { "resource_group" = module.iam.resource_group_name })
}

Requirements

Name Version
terraform >= 0.14
azurerm 2.49.0

Providers

Name Version
azurerm 2.49.0

Modules

Name Source Version
aks ../modules/aks
iam ../modules/iam
storage ../modules/storage
vnet ../modules/vnet

Resources

Name Type
azurerm_subscription.current data source

Inputs

Name Description Type Default Required
environment Name of the environment where infrastructure being built. string n/a yes
kubernetes_version version of the kubernetes cluster string "1.19.9" no
max_count Maximum Node Count number 5 no
min_count Minimum Node Count number 3 no
name AKS name in Azure string n/a yes
node_count Number of AKS worker nodes number 5 no
private_service_endpoints service endpoints to attach Private Subnets. list(string)
[
"Microsoft.Storage"
]
no
private_subnet_prefixes value list(string)
[
"10.1.1.0/24"
]
no
public_service_endpoints service endpoints to attche public Subnets. list(string) [] no
public_subnet_prefixes value list(string)
[
"10.1.0.0/24"
]
no
region Azure location where all the resources being created. string n/a yes
system_node_count Number of AKS worker nodes number 3 no
vm_size Specifies the size of the virtual machine. string Standard_E8_v4 no

Outputs

Name Description
aks_fqdn Azure kuberenetes service fqdn.
aks_id Azure kuberenetes service id.
connect_cluster Connection string to be used to configure kubectl.
resource_group The name of the resource group in which the resources will be created.
storage_account_id Azure Storage account id.