処理の実行
スタックIDを取得します。
コマンド:
cloudformation_stack_id=$( \
aws cloudformation list-stacks \
--query "StackSummaries[? \
StackName == \`${CLOUDFORMATION_STACK_NAME}\` \
&& StackStatus != \`DELETE_COMPLETE\` \
].StackId" \
--output text \
) \
&& echo ${cloudformation_stack_id}
結果(例):
arn:aws:cloudformation:ap-northeast-1:XXXXXXXXXXXX:stack/handson-cli-env-stack/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
CloudFormationスタックを削除します。
変数の確認:
cat << END
# CLOUDFORMATION_STACK_NAME:"handson-cli-env-stack"
CLOUDFORMATION_STACK_NAME="${CLOUDFORMATION_STACK_NAME}"
END
コマンド:
aws cloudformation delete-stack \
--stack-name ${CLOUDFORMATION_STACK_NAME}
結果(例):
完了確認
「CloudFormationスタック"handson-cli-env-stack"のステータスが"DELETE_COMPLETE"になっている。」ことを確認します。
コマンド:
cloudformation_stack_status=$(\
aws cloudformation list-stacks \
--query "StackSummaries[?StackId == \`${cloudformation_stack_id}\`].StackStatus" \
--output text \
) \
&& echo ${cloudformation_stack_status}
結果(例):