You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo"Warning: Failed to clear all resources after $max_attempts attempts."
50
+
fi
77
51
78
-
# remove server certificates
79
-
# unfortunately get-resources doesn't support iam server certificates
80
-
attempts=0
81
-
while [ $attempts-lt$max_attempts ];do
82
-
whileread -r name;do
83
-
if [ -z"$name" ];then
84
-
continue
85
-
fi
86
-
if aws iam list-server-certificate-tags --server-certificate-name "$name"| jq -e --arg ID "$IDENTIFIER"'.Tags[] | select(.Key=="Id" and .Value==$ID)'> /dev/null;then
87
-
echo"removing iam server certificate $name..."
88
-
aws iam delete-server-certificate --server-certificate-name "$name"
89
-
fi
90
-
done<<<"$(aws iam list-server-certificates | jq -r '.ServerCertificateMetadataList[].ServerCertificateName')"
# unfortunately get-resources doesn't support iam server certificates
109
+
echo"Clearing out server certificates if they were missed..."
110
+
attempts=0
111
+
while [ $attempts-lt$max_attempts ];do
112
+
whileread -r name;do
113
+
if [ -z"$name" ];then
114
+
continue
115
+
fi
116
+
if aws iam list-server-certificate-tags --server-certificate-name "$name"| jq -e --arg ID "$IDENTIFIER"'.Tags[] | select(.Key=="Id" and (.Value | contains($ID)))'> /dev/null;then
117
+
echo" removing iam server certificate $name..."
118
+
aws iam delete-server-certificate --server-certificate-name "$name"||true
119
+
fi
120
+
done<<<"$(aws iam list-server-certificates | jq -r '.ServerCertificateMetadataList[].ServerCertificateName')"
121
+
sleep $((attempts *10))
122
+
attempts=$((attempts +1))
123
+
done
124
+
125
+
# remove load balancer target groups
126
+
echo"Clearing out load balancer target groups if they were missed..."
127
+
attempts=0
128
+
while [ $attempts-lt$max_attempts ];do
129
+
whileread -r arn;do
130
+
if [ -z"$arn" ];then
131
+
continue
132
+
fi
133
+
echo" removing load balancer target group $arn..."
# For example, if you hit a quota limit and notice there a bunch of leftover secrets or target groups, you can run these commands to clean up all resources with the same Id as the leftover resources.
114
146
# for id in $(aws resourcegroupstaggingapi get-resources --no-cli-pager --resource-type-filters "elasticloadbalancing:targetgroup" --tag-filters "Key=Owner,Values=terraform-ci@suse.com" | jq -r '.ResourceTagMappingList[]?.Tags[] | select(.Key=="Id") | .Value'); do ./cleanup.sh "$id"; done
115
147
# for id in $(aws resourcegroupstaggingapi get-resources --no-cli-pager --resource-type-filters "secretsmanager:secret" --tag-filters "Key=Owner,Values=terraform-ci@suse.com" | jq -r '.ResourceTagMappingList[]?.Tags[] | select(.Key=="Id") | .Value'); do ./cleanup.sh "$id"; done
116
-
# for id in $(for name in $(aws iam list-server-certificates | jq -r '.ServerCertificateMetadataList[].ServerCertificateName'); do echo "$(aws iam list-server-certificate-tags --server-certificate-name "$name" | jq -r '.Tags[] | select(.Key=="Id").Value')"; done); do echo "$id"; done
148
+
# for id in $(for name in $(aws iam list-server-certificates | jq -r '.ServerCertificateMetadataList[].ServerCertificateName'); do echo "$(aws iam list-server-certificate-tags --server-certificate-name "$name" | jq -r '.Tags[] | select(.Key=="Id").Value')"; done); do ./cleanup.sh "$id"; done
0 commit comments