This module serves as a robust solution for managing Terraform state in Azure, encapsulating best practices in a simple, reusable module. It automates the provisioning of key Azure resources including a Resource Group, Storage Account, and Container, which are instrumental in managing Terraform state.
graph TD;
subgraph "Azure Cloud"
subgraph "Resource Group [RG]"
subgraph "Storage Account [SA]"
subgraph "Storage Container [SC]"
subgraph TS[Terraform State Blob]
subgraph "terraform.tfstate content"
VS[Versioned States]
end
end
end
end
end
end
Whether dealing with a single Terraform configuration or orchestrating multiple configurations, this module adapts to your needs, ensuring a standardized, secure, and efficient management of Terraform state. Through this module, managing Terraform state in Azure becomes a streamlined process, paving the way for a reliable and organized infrastructure setup.
To use this module, simply add the following to your Terraform configuration:
module "state_resources" {
source = "telia-oss/terraform-azure-terraform-init"
resource_group_name = var.resource_group_name
location = var.location
environment = var.environment
storage_account_name = var.storage_account_name
container_name = var.container_name
create_resource_group = true
create_storage_account = true
}
Name | Type |
---|---|
azurerm_resource_group.this | resource |
azurerm_storage_account.this | resource |
azurerm_storage_container.this | resource |
random_string.azurerm_storage_account | resource |
random_string.resource_group | resource |
azurerm_resource_group.this | data source |
azurerm_storage_account.this | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
account_replication_type | The replication type for the storage account. Valid options are LRS, GRS, RAGRS, and ZRS. | string |
"LRS" |
no |
account_tier | The performance tier of the storage account. Valid options are Standard or Premium. | string |
"Standard" |
no |
azurerm_create_resource_group | Boolean flag to control whether a new resource group should be created or use an existing one. | bool |
false |
no |
azurerm_create_storage_account | Boolean flag to control whether a new storage account should be created or use an existing one. | bool |
false |
no |
container_access_type | Defines the access level for the storage container. Valid options are private, blob, or container. | string |
"private" |
no |
container_name | Name of the storage container within the Azure Storage Account where the Terraform state file will be stored. | string |
"terraform-state" |
no |
default_tags | A map of default tags to assign to all resources created by this module. | map(string) |
{ |
no |
location | Azure region where all resources in this module will be created. | string |
"westus2" |
no |
name_prefix | Prefix used to name all resources created by this module, ensuring a consistent naming convention. | string |
"" |
no |
resource_group_name | Name of the Azure Resource Group where resources will be created. If left empty, a new resource group is created. | string |
"" |
no |
storage_account_name | Name of the Azure Storage Account to be used or created for storing Terraform state. | string |
"" |
no |
user_defined_tags | A map of user-defined tags to assign to all resources created by this module. | map(string) |
{} |
no |
retention_days | The number of days that the state file should be retained. | number |
30 |
no |
Name | Description |
---|---|
backend_config | The backend configuration for the Terraform state. |
container_name | The name of the container in which the Terraform state is stored. |
container_url | The URL of the container in which the Terraform state is stored. |
name_prefix | The name prefix used for all resources created by this module. |
resource_group_name | The name of the resource group in which the Terraform state is stored. |
storage_account_name | The name of the storage account in which the Terraform state is stored. |
If you'd like to contribute to this module, please follow the guidelines in the contributing file.