Skip to content

Instantly share code, notes, and snippets.

@oscarnevarezleal
Created February 1, 2021 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarnevarezleal/36551bfc7d45fc7fa8cc551147deca57 to your computer and use it in GitHub Desktop.
Save oscarnevarezleal/36551bfc7d45fc7fa8cc551147deca57 to your computer and use it in GitHub Desktop.
Clean up AWS Cloudmap Namespace
# This cleans every cloudmap and every service
# from https://www.appmeshworkshop.com/cleanup/cloudmap/
NAMESPACE=$(aws servicediscovery list-namespaces | \
jq -r ' .Namespaces[] |
select ( .Properties.HttpProperties.HttpName == "appmeshworkshop.pvt.local" ) | .Id ');
SERVICE_ID=$(aws servicediscovery list-services --filters Name="NAMESPACE_ID",Values=$NAMESPACE,Condition="EQ" | jq -r ' .Services[] | [ .Id ] | @tsv ' )
aws servicediscovery list-instances --service-id $SERVICE_ID | jq -r ' .Instances[] | [ .Id ] | @tsv ' |\
while IFS=$'\t' read -r instanceId; do
aws servicediscovery deregister-instance --service-id $SERVICE_ID --instance-id $instanceId
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment