Registering Instances
To register 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.
-
On the Namespaces page, choose the namespace that contains the service that you want to use as a template for registering a service instance.
-
On the Namespace:
namespace-name
page, choose the service that you want to use. -
On the Service:
service-name
page, choose Register service instance. -
On the Register service instance page, enter the applicable values. For more information, see Values That You Specify When You Register or Update Instances.
-
Choose Register service instance.
- AWS CLI
-
-
When you submit a
RegisterInstance
request:-
For each DNS record that you define in the service that's specified by
ServiceId
, a record is created or updated in the hosted zone that's associated with the corresponding namespace. -
If the service includes
HealthCheckConfig
, a health check is created based on the settings in the health check configuration. -
Any health checks are associated with each of the new or updated records.
Register a service instance with the
register-instance
command (replace thered
values with your own).aws servicediscovery register-instance \ --service-id
srv-xxxxxxxxx
\ --instance-idmyservice-xx
\ --attributes=AWS_INSTANCE_IPV4=172.2.1.3,AWS_INSTANCE_PORT=808
-
-
- 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')
-
When you submit a
RegisterInstance
request:-
For each DNS record that you define in the service that's specified by
ServiceId
, a record is created or updated in the hosted zone that's associated with the corresponding namespace. -
If the service includes
HealthCheckConfig
, a health check is created based on the settings in the health check configuration. -
Any health checks are associated with each of the new or updated records.
Register a service instance with
register_instance()
(replace thered
values with your own).response = client.register_instance( Attributes={ 'AWS_INSTANCE_IPV4': '172.2.1.3', 'AWS_INSTANCE_PORT': '808', }, InstanceId='
myservice-xx
', ServiceId='srv-xxxxxxxxx
', ) # If you want to see the response print(response)Example response output
{ 'OperationId': '4yejorelbukcjzpnr6tlmrghsjwpngf4-k95yg2u7', 'ResponseMetadata': { '...': '...', }, }
-
-