File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -759,6 +759,25 @@ function _list_cloudwatch_dashboards() {
759759 done
760760}
761761
762+ function _delete_cloudwatch_dashboards() {
763+ local workspace=$1
764+ if [ -z " $workspace " ]; then
765+ echo " Error: Workspace substring must be provided. Refusing to delete all dashboards."
766+ return 1
767+ fi
768+
769+ local dashboards=$( aws cloudwatch list-dashboards --output json)
770+ dashboards=$( echo " $dashboards " | jq -r --arg SUBSTRING " $workspace " ' .DashboardEntries[] | select(.DashboardName | contains($SUBSTRING)) | .DashboardName' )
771+
772+ [ -z " $dashboards " ] && echo " No CloudWatch Dashboards found for deletion." && return 0
773+
774+ echo " Deleting the following CloudWatch Dashboards:"
775+ for dashboard in $dashboards ; do
776+ echo " $dashboard "
777+ done
778+ aws cloudwatch delete-dashboards --dashboard-names $dashboards
779+ }
780+
762781function _list_iam_instance_profiles() {
763782 local workspace=$1
764783 local profiles=$( aws iam list-instance-profiles --output json)
@@ -1008,6 +1027,7 @@ function _delete_workspace_resources() {
10081027 _delete_lambda_layers " $TERRAFORM_WORKSPACE "
10091028 _delete_cloudwatch_alarms " $TERRAFORM_WORKSPACE "
10101029 _delete_sns_subscriptions " $TERRAFORM_WORKSPACE "
1030+ _delete_cloudwatch_dashboards " $TERRAFORM_WORKSPACE "
10111031}
10121032
10131033# Parse args
You can’t perform that action at this time.
0 commit comments