1# 2# Copyright 2022 Google LLC 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# https://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16set -eo pipefail 17 18helperDir="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" 19pushd "$helperDir/.." >/dev/null 20 21# Execute 'predestroy.sh' scripts for any active modules 22source ./helpers/common.sh 23allModules=$(listAllModules) 24activeModules=$(getActiveTerraformModules) 25IFS=',' 26for module in $allModules; do 27 friendlyName=$(getFriendlyOutputName "$module") 28 if ! contains "$activeModules" "$friendlyName"; then 29 continue # Skip unless active. 30 fi 31 32 if [[ -f "../$module/.cloud/predestroy.sh" ]]; then 33 # shellcheck disable=SC1090 34 source "../$module/.cloud/predestroy.sh" 35 fi 36done 37 38terraform destroy -auto-approve 39popd >/dev/null 40