Created
          February 1, 2021 18:32 
        
      - 
      
 - 
        
Save oscarnevarezleal/36551bfc7d45fc7fa8cc551147deca57 to your computer and use it in GitHub Desktop.  
    Clean up AWS Cloudmap Namespace
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # 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