Deregistering an AWS Cloud Map service instance
Before you can delete a service, you must deregister all service instances that were registered using the service.
To deregister a service instance, perform the following procedure.
- AWS Management Console
-
Sign in to the AWS Management Console and open the AWS Cloud Map console at https://console.aws.amazon.com/cloudmap/
. -
In the navigation pane, choose Namespaces.
-
Choose the option for the namespace that contains the service instance that you want to deregister.
-
On the Namespace:
namespace-name
page, choose the service you used to register the service instance. -
On the Service:
service-name
page, choose the service instance that you want to deregister. -
Choose Deregister.
-
Confirm that you want to deregister the service instance.
- AWS CLI
-
-
Deregister a service instance with the
deregister-instance
command (replace thered
values with your own). This command deletes the Amazon Route 53 DNS records and any health checks that AWS Cloud Map created for the specified instance.aws servicediscovery deregister-instance \ --service-id
srv-xxxxxxxxx
\ --instance-idmyservice-53
-
- AWS SDK for Python (Boto3)
-
-
If you don't already have
Boto3
installed, you can find instructions for installing, configuring, and usingBoto3
here. -
Import
Boto3
and useservicediscovery
as your service.import boto3 client = boto3.client('servicediscovery')
-
Deregister a service instance with
deregister-instance()
(replace thered
values with your own). This command deletes the Amazon Route 53 DNS records and any health checks that AWS Cloud Map created for the specified instance.response = client.deregister_instance( InstanceId='myservice-53', ServiceId='srv-xxxxxxxxx', ) # If you want to see the response print(response)
Example response output
{ 'OperationId': '4yejorelbukcjzpnr6tlmrghsjwpngf4-k98rnaiq', 'ResponseMetadata': { '...': '...', }, }
-