User Tools

Site Tools


cloud:aws:servicediscovery

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
cloud:aws:servicediscovery [2018/11/08 13:50] skipidarcloud:aws:servicediscovery [2023/11/01 07:13] (current) – ↷ Page moved from business_process_management:camunda:cloud:aws:servicediscovery to cloud:aws:servicediscovery skipidar
Line 66: Line 66:
 # ping the service # ping the service
 echo -e "Service available under '$servicename.$dnsnamespace'" echo -e "Service available under '$servicename.$dnsnamespace'"
 +
 +</sxh>
 +
 +
 +
 +
 +Remove service
 +
 +
 +
 +
 +<sxh shell>
 +#/bin/bash -e
 +
 +# Removes the services and the namespace, if no instances are available in the service anymore
 +
 +
 +#stop on error
 +#set -e
 +
 +
 +######## ARGUMENTS
 +
 +
 +# retrieve the building ID: zurich-klinik
 +buildingName=${1?Pass in the building id.}
 +
 +
 +
 +
 +
 +
 +########## SCRIPT START 
 +
 +
 +dnsnamespace="navvis.local"
 +servicename="${buildingName}.renderer"
 +
 +
 +
 +# get the instance id by service
 +serviceId=$(aws servicediscovery list-services --query "\"Services\"[?Name==\`$servicename\`].Id" --output text) 2> /dev/null
 +echo "ServiceId: $serviceId"
 +
 +# get the instace id by service
 +instanceId=$(aws servicediscovery list-instances --service-id $serviceId --query "\"Instances\"[0].Id" --output text)  2> /dev/null
 +echo "InstanceId: $instanceId"
 +
 +# retrieve the namespace id
 +namespaceId=$(aws servicediscovery list-namespaces --query "\"Namespaces\"[?Name==\`$dnsnamespace\`].Id" --output text)  2> /dev/null
 +echo "NameSpaceId: $namespaceId"
 +
 +# deregister the instance
 +aws servicediscovery deregister-instance --service-id $serviceId --instance-id $instanceId  2> /dev/null
 +
 +# deregister the service, will only work if no instances are left
 +aws servicediscovery delete-service --id $serviceId  2> /dev/null
 +
 +# deregister the namespace, will only work if no services
 +aws servicediscovery delete-namespace --id $namespaceId  2> /dev/null
 +
 +
 +
 +# ping the service
 +echo -e "Removed service '$servicename.$dnsnamespace'"
  
 </sxh> </sxh>
  
cloud/aws/servicediscovery.1541685005.txt.gz · Last modified: (external edit)