Skip to content

Commit

Permalink
Merged in dev/fabien/MPC-5012-reorder-terraform.sh-finalizers (pull r…
Browse files Browse the repository at this point in the history
…equest elastic#541)

MPC-5012: delete ec2 instances before attempting redis flush

* delete ec2 instances before attempting redis flush


Approved-by: Can Yildiz
  • Loading branch information
fabien committed Mar 22, 2022
1 parent b3324bc commit f04195d
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions aws/ams-cluster-v1-tf/terraform.sh
Expand Up @@ -191,6 +191,23 @@ terraform apply \
-parallelism=50 \
-auto-approve

echo "deleting ems, merger, recorder ec2 instances"
aws \
--profile ${STACK_PROFILE} \
--region ${STACK_REGION} \
ec2 describe-instances \
--query 'Reservations[*].Instances[*].{ID:InstanceId}' \
--filters "Name=instance-state-name,Values=running,stopped" \
"Name=tag:Role,Values=ems,merger,recorder" \
"Name=tag:StackName,Values=${STACK_NAME}" \
--output text |
xargs aws \
--profile ${STACK_PROFILE} \
--region ${STACK_REGION} \
--no-cli-pager \
ec2 terminate-instances \
--instance-ids

OVERRIDES=$(
cat <<EOT
{
Expand Down Expand Up @@ -244,20 +261,3 @@ kubectl \
--restart Never \
--overrides "$(echo ${OVERRIDES} | sed 's/TARGET/EMS_REDIS_URL/')" \
flush-ems-redis

echo "deleting ems, merger, recorder ec2 instances"
aws \
--profile ${STACK_PROFILE} \
--region ${STACK_REGION} \
ec2 describe-instances \
--query 'Reservations[*].Instances[*].{ID:InstanceId}' \
--filters "Name=instance-state-name,Values=running,stopped" \
"Name=tag:Role,Values=ems,merger,recorder" \
"Name=tag:StackName,Values=${STACK_NAME}" \
--output text |
xargs aws \
--profile ${STACK_PROFILE} \
--region ${STACK_REGION} \
--no-cli-pager \
ec2 terminate-instances \
--instance-ids

0 comments on commit f04195d

Please sign in to comment.