Skip to content

Commit

Permalink
Merge pull request #253 from DFE-Digital/ci-storage-blob-lifecycle
Browse files Browse the repository at this point in the history
Delete CI reports after 14 days
  • Loading branch information
DrizzlyOwl authored Nov 16, 2023
2 parents 7e5a909 + 543d9c0 commit 1a4fc10
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ If everything looks good, answer `yes` and wait for the new infrastructure to be

| Name | Version |
|------|---------|
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 3.77.0 |
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 3.79.0 |

## Modules

Expand All @@ -151,6 +151,7 @@ If everything looks good, answer `yes` and wait for the new infrastructure to be
| [azurerm_monitor_diagnostic_setting.ci-test-reports](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting) | resource |
| [azurerm_storage_account.ci-test-reports](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account) | resource |
| [azurerm_storage_container.ci-test-reports](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_container) | resource |
| [azurerm_storage_management_policy.ci-test-reports](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_management_policy) | resource |
| [azurerm_storage_account_blob_container_sas.ci-test-reports](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/storage_account_blob_container_sas) | data source |

## Inputs
Expand Down
26 changes: 26 additions & 0 deletions terraform/ci-storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@ resource "azurerm_monitor_diagnostic_setting" "ci-test-reports" {
}
}

resource "azurerm_storage_management_policy" "ci-test-reports" {
count = local.enable_ci_report_storage_container ? 1 : 0

storage_account_id = azurerm_storage_account.ci-test-reports[0].id

rule {
name = "ci-report-cool-off"
enabled = true

filters {
blob_types = ["blockBlob"]
}

actions {
base_blob {
tier_to_cool_after_days_since_creation_greater_than = 7
delete_after_days_since_creation_greater_than = 14
}

snapshot {
delete_after_days_since_creation_greater_than = 14
}
}
}
}

data "azurerm_storage_account_blob_container_sas" "ci-test-reports" {
count = local.enable_ci_report_storage_container ? 1 : 0

Expand Down

0 comments on commit 1a4fc10

Please sign in to comment.