{"id":28509789,"url":"https://github.com/cloudandthings/terraform-azurerm-storage-lifecyclepolicy","last_synced_at":"2026-02-24T09:04:46.002Z","repository":{"id":285394363,"uuid":"955178631","full_name":"cloudandthings/terraform-azurerm-storage-lifecyclepolicy","owner":"cloudandthings","description":"Storage Lifecycle Custom Policy","archived":false,"fork":false,"pushed_at":"2025-03-31T13:06:18.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-30T15:37:00.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudandthings.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-26T08:28:34.000Z","updated_at":"2025-03-31T13:06:22.000Z","dependencies_parsed_at":"2025-03-31T14:27:08.265Z","dependency_job_id":"73bf6eff-e84a-4ea2-8a43-474843246f7e","html_url":"https://github.com/cloudandthings/terraform-azurerm-storage-lifecyclepolicy","commit_stats":null,"previous_names":["cloudandthings/terraform-azurerm-storage-lifecyclepolicy"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cloudandthings/terraform-azurerm-storage-lifecyclepolicy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudandthings%2Fterraform-azurerm-storage-lifecyclepolicy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudandthings%2Fterraform-azurerm-storage-lifecyclepolicy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudandthings%2Fterraform-azurerm-storage-lifecyclepolicy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudandthings%2Fterraform-azurerm-storage-lifecyclepolicy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudandthings","download_url":"https://codeload.github.com/cloudandthings/terraform-azurerm-storage-lifecyclepolicy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudandthings%2Fterraform-azurerm-storage-lifecyclepolicy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29777623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T04:54:30.205Z","status":"ssl_error","status_checked_at":"2026-02-24T04:53:58.628Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-08T22:37:17.398Z","updated_at":"2026-02-24T09:04:43.894Z","avatar_url":"https://github.com/cloudandthings.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Azure Storage Lifecycle Management Policy Terraform Module\n\nThis Terraform module creates and assigns an Azure Policy that enforces lifecycle management on Azure Storage accounts. The policy can be applied at either management group, subscription level or storage account level.\n\n## Features\n\n- Enforce consistent lifecycle management across all storage accounts\n- Configure days for transition to cool tier, archive tier, and deletion\n- Apply at management group, subscription, or individual storage account level\n- Configurable policy effect (Deploy, Audit, or Disable)\n- Custom prefix filters for targeted application\n\n## Prerequisites\n\n- [Terraform](https://www.terraform.io/downloads.html) \u003e= 1.0\n- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) \u003e= 2.20.0\n- Azure subscription or management group with appropriate permissions\n\n# Usage\n\n## Example usage of the Azure Storage Lifecycle Management Policy Module\n\n## Example 1: Apply at subscription level\n\n```\nmodule \"storage_lifecycle_subscription\" {\nsource = \"../\" # Path to the module directory\n\nscope_type = \"subscription\"\nsubscription_id = \"00000000-0000-0000-0000-000000000000\" # Replace with your subscription ID\n\ndays_to_cool_tier = 30\ndays_to_archive_tier = 90\ndays_to_delete = 365\ndays_to_delete_snapshots = 30\n\nprefix_filters = [\"container1/\", \"backups/\"]\n\npolicy_effect = \"DeployIfNotExists\"\n}\n```\n\n## Example 2: Apply at management group level\n\n```\nmodule \"storage_lifecycle_management_group\" {\nsource = \"../\" # Path to the module directory\n\nscope_type = \"management_group\"\nmanagement_group_id = \"mg-production\" # Use the ID of the management group\n\ndays_to_cool_tier = 45\ndays_to_archive_tier = 120\ndays_to_delete = 730\ndays_to_delete_snapshots = 45\n\nprefix_filters = [\"logs/\", \"metrics/\"]\n\npolicy_effect = \"AuditIfNotExists\" # Start with audit before enforcing\n}\n```\n\n## Example 3: Apply to a specific storage account\n\n```\nmodule \"storage_lifecycle_storage_account\" {\nsource = \"../\" # Path to the module directory\n\nscope_type = \"storage_account\"\nsubscription_id = \"00000000-0000-0000-0000-000000000000\" # Replace with your subscription ID\nstorage_account_name = \"mystorageaccount\" # Replace with your storage account name\nresource_group_name = \"myresourcegroup\" # Replace with your resource group name\n\ndays_to_cool_tier = 60\ndays_to_archive_tier = 180\ndays_to_delete = 365\ndays_to_delete_snapshots = 30\n\nprefix_filters = [\"critical/\", \"important/\"]\n\npolicy_effect = \"DeployIfNotExists\" # Start with audit before enforcing but here we showcase DINE approach in our example.\n}\n```\n\n# Terraform Documentation\n\n## Requirements\n\n| Name                                                                     | Version  |\n| ------------------------------------------------------------------------ | -------- |\n| \u003ca name=\"requirement_terraform\"\u003e\u003c/a\u003e [terraform](#requirement_terraform) | \u003e= 1.0.0 |\n| \u003ca name=\"requirement_azurerm\"\u003e\u003c/a\u003e [azurerm](#requirement_azurerm)       | \u003e=3.0.0  |\n| \u003ca name=\"requirement_azurerm\"\u003e\u003c/a\u003e [azurerm](#requirement_azurerm)       | \u003e= 3.0.0 |\n\n## Providers\n\n| Name                                                         | Version          |\n| ------------------------------------------------------------ | ---------------- |\n| \u003ca name=\"provider_azurerm\"\u003e\u003c/a\u003e [azurerm](#provider_azurerm) | \u003e=3.0.0 \u003e= 3.0.0 |\n\n## Modules\n\nNo modules.\n\n## Resources\n\n| Name                                                                                                                                                                                  | Type        |\n| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |\n| [azurerm_management_group_policy_assignment.mg_storage_lifecycle](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_group_policy_assignment) | resource    |\n| [azurerm_policy_definition.storage_lifecycle](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/policy_definition)                                      | resource    |\n| [azurerm_resource_policy_assignment.sa_storage_lifecycle](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_policy_assignment)                 | resource    |\n| [azurerm_role_assignment.mg_storage_lifecycle](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment)                                       | resource    |\n| [azurerm_role_assignment.sa_storage_lifecycle](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment)                                       | resource    |\n| [azurerm_role_assignment.sub_storage_lifecycle](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment)                                      | resource    |\n| [azurerm_subscription_policy_assignment.sub_storage_lifecycle](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subscription_policy_assignment)        | resource    |\n| [azurerm_subscription.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subscription)                                                       | data source |\n\n## Inputs\n\n| Name                                                                                                      | Description                                                                                                                                                                            | Type           | Default               | Required |\n| --------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | --------------------- | :------: |\n| \u003ca name=\"input_days_to_archive_tier\"\u003e\u003c/a\u003e [days_to_archive_tier](#input_days_to_archive_tier)             | The number of days after which a blob should be moved to the archive tier                                                                                                              | `number`       | `90`                  |    no    |\n| \u003ca name=\"input_days_to_cool_tier\"\u003e\u003c/a\u003e [days_to_cool_tier](#input_days_to_cool_tier)                      | The number of days after which a blob should be moved to the cool tier                                                                                                                 | `number`       | `30`                  |    no    |\n| \u003ca name=\"input_days_to_delete\"\u003e\u003c/a\u003e [days_to_delete](#input_days_to_delete)                               | The number of days after which a blob should be deleted                                                                                                                                | `number`       | `365`                 |    no    |\n| \u003ca name=\"input_days_to_delete_snapshots\"\u003e\u003c/a\u003e [days_to_delete_snapshots](#input_days_to_delete_snapshots) | The number of days after which blob snapshots should be deleted                                                                                                                        | `number`       | `30`                  |    no    |\n| \u003ca name=\"input_location\"\u003e\u003c/a\u003e [location](#input_location)                                                 | The Azure region to use for deployments                                                                                                                                                | `string`       | `\"westeurope\"`        |    no    |\n| \u003ca name=\"input_management_group_id\"\u003e\u003c/a\u003e [management_group_id](#input_management_group_id)                | The ID of the management group to assign the policy to. Required if scope_type is 'management_group'                                                                                   | `string`       | `null`                |    no    |\n| \u003ca name=\"input_policy_effect\"\u003e\u003c/a\u003e [policy_effect](#input_policy_effect)                                  | The effect of the policy. Valid values are 'DeployIfNotExists', 'AuditIfNotExists', or 'Disabled'                                                                                      | `string`       | `\"DeployIfNotExists\"` |    no    |\n| \u003ca name=\"input_prefix_filters\"\u003e\u003c/a\u003e [prefix_filters](#input_prefix_filters)                               | A list of blob prefix filters to apply the lifecycle policy to                                                                                                                         | `list(string)` | `[]`                  |    no    |\n| \u003ca name=\"input_resource_group_name\"\u003e\u003c/a\u003e [resource_group_name](#input_resource_group_name)                | The name of the resource group containing the storage account. Required if scope_type is 'storage_account'                                                                             | `string`       | `null`                |    no    |\n| \u003ca name=\"input_scope_type\"\u003e\u003c/a\u003e [scope_type](#input_scope_type)                                           | The type of scope to assign the policy to. Valid values are 'management_group', 'subscription', or 'storage_account'                                                                   | `string`       | `\"subscription\"`      |    no    |\n| \u003ca name=\"input_storage_account_name\"\u003e\u003c/a\u003e [storage_account_name](#input_storage_account_name)             | The name of the storage account to assign the policy to. Required if scope_type is 'storage_account'                                                                                   | `string`       | `null`                |    no    |\n| \u003ca name=\"input_subscription_id\"\u003e\u003c/a\u003e [subscription_id](#input_subscription_id)                            | The ID of the subscription to assign the policy to. Required if scope_type is 'subscription'. If not provided and scope_type is 'subscription', the current subscription will be used. | `string`       | `null`                |    no    |\n\n## Outputs\n\n| Name                                                                                                              | Description                                                |\n| ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |\n| \u003ca name=\"output_applied_scope\"\u003e\u003c/a\u003e [applied_scope](#output_applied_scope)                                        | The scope where the policy was applied                     |\n| \u003ca name=\"output_policy_assignment_id\"\u003e\u003c/a\u003e [policy_assignment_id](#output_policy_assignment_id)                   | The ID of the policy assignment                            |\n| \u003ca name=\"output_policy_assignment_identity\"\u003e\u003c/a\u003e [policy_assignment_identity](#output_policy_assignment_identity) | The managed identity associated with the policy assignment |\n| \u003ca name=\"output_policy_id\"\u003e\u003c/a\u003e [policy_id](#output_policy_id)                                                    | The ID of the created policy definition                    |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudandthings%2Fterraform-azurerm-storage-lifecyclepolicy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudandthings%2Fterraform-azurerm-storage-lifecyclepolicy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudandthings%2Fterraform-azurerm-storage-lifecyclepolicy/lists"}