Skip to content

Instantly share code, notes, and snippets.

@hkboujrida
Created January 12, 2024 08:46
Show Gist options
  • Save hkboujrida/b21408bb7323a1c4d8d531e88db7f369 to your computer and use it in GitHub Desktop.
Save hkboujrida/b21408bb7323a1c4d8d531e88db7f369 to your computer and use it in GitHub Desktop.
provider "azurerm" {
features {}
}
data "azurerm_container_registry" "acr" {
name = var.registry_name
resource_group_name = var.resource_group_name
}
resource "azurerm_container_registry_task" "daily_purge_prod_images" {
name = "daily_purge_images"
container_registry_id = data.azurerm_container_registry.acr.id
agent_setting {
cpu = 2
}
platform {
architecture = "amd64"
os = "Linux"
variant = null
}
encoded_step {
task_content = base64encode(yamlencode({
version : "v1.1.0",
steps : [
{
cmd : "mcr.microsoft.com/acr/acr-cli:0.5 purge --untagged --ago 6m --filter '*:[^0-9.]+$' --keep 3"
disableWorkingDirectoryOverride : true,
timeout : 3600
}
]
}))
values = {}
}
timer_trigger {
name = "daily at 1AM"
schedule = "0 1 * * *"
}
base_image_trigger {
type = "Runtime"
name = "defaultBaseimageTriggerName"
update_trigger_payload_type = "Default"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment