Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amend destroy_env_no_terraform.sh to purge container repos #4230

Merged
merged 7 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ENHANCEMENTS:
* Enhance DPI of Linux display ([[#4200](https://github.com/microsoft/AzureTRE/issues/4200)])
* Update Admin VM versions ([[#4217](https://github.com/microsoft/AzureTRE/issues/4217)])
* Update devcontainer/RP/API package versions: base image, docker, az cli, YQ ([#4225](https://github.com/microsoft/AzureTRE/pull/4225))
* Purge container repos individually in when using `make tre-destroy` ([#4230](https://github.com/microsoft/AzureTRE/pull/4230))
* Upgrade Python version from 3.8 to 3.12 ([#3949](https://github.com/microsoft/AzureTRE/issues/3949))Upgrade Python version from 3.8 to 3.12 (#3949)
* Disable storage account key usage ([[#4227](https://github.com/microsoft/AzureTRE/issues/4227)])
* Update Guacamole dependencies ([[#4232](https://github.com/microsoft/AzureTRE/issues/4232)])
Expand Down
24 changes: 24 additions & 0 deletions devops/scripts/destroy_env_no_terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,35 @@ if [ "${workspace}" != "0" ]; then
| xargs -P 10 -I {} az rest --method delete --uri "{}?api-version=2020-08-01"
fi

# delete container repositories individually otherwise defender doesn't purge image scans
function purge_container_repositories() {
local rg=$1

local acrs
acrs=$(az acr list --resource-group "$rg" --query [].name --output tsv)

local acr
for acr in $acrs; do
echo "Found container registry ${acr}, deleting repositories..."

local repositories
repositories=$(az acr repository list --name "$acr" --output tsv)

local repository
for repository in $repositories; do
echo " Deleting: $repository"
az acr repository delete --name "$acr" --repository "$repository" --yes --output none
done
done
}

# this will find the mgmt, core resource groups as well as any workspace ones
# we are reverse-sorting to first delete the workspace groups (might not be
# good enough because we use no-wait sometimes)
az group list --query "[?starts_with(name, '${core_tre_rg}')].[name]" -o tsv | sort -r |
while read -r rg_item; do
purge_container_repositories "$rg_item"

echo "Deleting resource group: ${rg_item}"
az group delete --resource-group "${rg_item}" --yes ${no_wait_option}
done
Loading