I have a pre-existing ACR and I need to enable soft-deletion policy using terraform. I don't want to use null-resource, is there any other way I can achieve this?
resource "null_resource" "soft_delete_policy" {
provisioner "local-exec" {
command = "az acr config soft-delete update -r MyRegistry --days 7 --status Enabled"
}
You could use the AzAPI provider:
First, run
az acr show -g <your-resource-group> -n <your-acr-name> -o jsonto get the container registry's resource configuration in JSON format.Then, construct an azapi_resource in your Terraform configuration using the relevant bits of the JSON:
Next, import the AzAPI resource into your Terraform configuration:
Update the AzAPI resource in the Terraform config to set soft delete policy:
Finally, apply the change via
terraform apply