File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -197,6 +197,22 @@ if [ -z "$apps" ]; then
197197else
198198 while IFS= read -r app; do
199199 [ -z " $app " ] && continue
200+ # AppRegistry refuses delete while resources are associated.
201+ # Disassociate every resource type listed under the app, then delete.
202+ echo " disassociating resources for: $app "
203+ assoc=$( aws servicecatalog-appregistry list-associated-resources \
204+ --application " $app " \
205+ --query ' resources[].[arn,resourceType]' \
206+ --output text 2> /dev/null | grep -v ' ^$' || true)
207+ if [ -n " $assoc " ]; then
208+ while IFS=$' \t ' read -r arn rtype; do
209+ [ -z " $arn " ] && continue
210+ echo " disassociate $rtype : $arn "
211+ aws servicecatalog-appregistry disassociate-resource \
212+ --application " $app " --resource-type " $rtype " --resource " $arn " \
213+ 2>&1 | sed ' s/^/ /' || true
214+ done <<< " $assoc"
215+ fi
200216 echo " delete appregistry: $app "
201217 aws servicecatalog-appregistry delete-application --application " $app " 2>&1 | sed ' s/^/ /' || true
202218 done <<< " $apps"
You can’t perform that action at this time.
0 commit comments