Skip to content

Commit c893446

Browse files
[v2] CLI examples servicediscovery (#9768)
1 parent dfe7600 commit c893446

23 files changed

+590
-106
lines changed
Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
**To create a service**
1+
**Example 1: To create a service using namespace ID**
22

33
The following ``create-service`` example creates a service. ::
44

55
aws servicediscovery create-service \
66
--name myservice \
77
--namespace-id ns-ylexjili4cdxy3xm \
8-
--dns-config "NamespaceId=ns-ylexjili4cdxy3xm,RoutingPolicy=MULTIVALUE,DnsRecords=[{Type=A,TTL=60}]"
8+
--dns-config "RoutingPolicy=MULTIVALUE,DnsRecords=[{Type=A,TTL=60}]"
99

1010
Output::
1111

1212
{
13-
"Service": {
14-
"Id": "srv-p5zdwlg5uvvzjita",
15-
"Arn": "arn:aws:servicediscovery:us-west-2:803642222207:service/srv-p5zdwlg5uvvzjita",
13+
"Service": {
14+
"Id": "srv-abcd1234xmpl5678",
15+
"Arn": "arn:aws:servicediscovery:us-west-2:123456789012:service/srv-abcd1234xmpl5678",
16+
"ResourceOwner": "123456789012",
1617
"Name": "myservice",
17-
"NamespaceId": "ns-ylexjili4cdxy3xm",
18+
"NamespaceId": "ns-abcd1234xmpl5678",
1819
"DnsConfig": {
19-
"NamespaceId": "ns-ylexjili4cdxy3xm",
20+
"NamespaceId": "ns-abcd1234xmpl5678",
2021
"RoutingPolicy": "MULTIVALUE",
2122
"DnsRecords": [
2223
{
@@ -25,10 +26,49 @@ Output::
2526
}
2627
]
2728
},
28-
"CreateDate": 1587081768.334,
29-
"CreatorRequestId": "567c1193-6b00-4308-bd57-ad38a8822d25"
29+
"Type": "DNS_HTTP",
30+
"CreateDate": "2025-08-18T13:45:31.023000-05:00",
31+
"CreatorRequestId": "abcd1234-5678-90ab-cdef-xmpl12345678",
32+
"CreatedByAccount": "123456789012"
3033
}
3134
}
3235

33-
For more information, see `Creating services <https://docs.aws.amazon.com/cloud-map/latest/dg/creating-services.html>`__ in the *AWS Cloud Map Developer Guide*.
36+
For more information, see `Creating an AWS Cloud Map service for an application component <https://docs.aws.amazon.com/cloud-map/latest/dg/creating-services.html>`__ in the *AWS Cloud Map Developer Guide*.
37+
38+
**Example 2: To create a service using namespace ARN**
39+
40+
The following ``create-service`` example creates a service using a namespace ARN instead of namespace ID. Specifying a namespace ARN is necessary when creating a service in a shared namespace. ::
41+
42+
aws servicediscovery create-service \
43+
--name myservice-arn \
44+
--namespace-id arn:aws:servicediscovery:us-west-2:123456789012:namespace/ns-abcd1234xmpl5678 \
45+
--dns-config "RoutingPolicy=MULTIVALUE,DnsRecords=[{Type=A,TTL=60}]"
46+
47+
Output::
48+
49+
{
50+
"Service": {
51+
"Id": "srv-abcd1234xmpl5678",
52+
"Arn": "arn:aws:servicediscovery:us-west-2:123456789012:service/srv-abcd1234xmpl5678",
53+
"ResourceOwner": "123456789012",
54+
"Name": "myservice-arn",
55+
"NamespaceId": "ns-abcd1234xmpl5678",
56+
"DnsConfig": {
57+
"NamespaceId": "ns-abcd1234xmpl5678",
58+
"RoutingPolicy": "MULTIVALUE",
59+
"DnsRecords": [
60+
{
61+
"Type": "A",
62+
"TTL": 60
63+
}
64+
]
65+
},
66+
"Type": "DNS_HTTP",
67+
"CreateDate": "2025-08-18T13:45:31.023000-05:00",
68+
"CreatorRequestId": "abcd1234-5678-90ab-cdef-xmpl12345678",
69+
"CreatedByAccount": "123456789012"
70+
}
71+
}
72+
73+
For more information, see `Shared AWS Cloud Map namespaces <https://docs.aws.amazon.com/cloud-map/latest/dg/sharing-namespaces.html>`__ in the *AWS Cloud Map Developer Guide*.
3474

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
1-
**To delete a namespace**
1+
**Example 1: To delete a namespace**
22

33
The following ``delete-namespace`` example deletes a namespace. ::
44

55
aws servicediscovery delete-namespace \
6-
--id ns-ylexjili4cdxy3xm
6+
--id ns-abcd1234xmpl5678
77

88
Output::
99

1010
{
11-
"OperationId": "gv4g5meo7ndmeh4fqskygvk23d2fijwa-k98y6drk"
11+
"OperationId": "abcd1234-5678-90ab-cdef-xmpl12345678"
1212
}
1313

1414
To confirm that the operation succeeded, you can run ``get-operation``. For more information, see `get-operation <https://docs.aws.amazon.com/cli/latest/reference/servicediscovery/get-operation.html>`__ .
1515

16-
For more information, see `Deleting namespaces <https://docs.aws.amazon.com/cloud-map/latest/dg/deleting-namespaces.html>`__ in the *AWS Cloud Map Developer Guide*.
16+
For more information, see `Deleting an AWS Cloud Map namespace <https://docs.aws.amazon.com/cloud-map/latest/dg/deleting-namespaces.html>`__ in the *AWS Cloud Map Developer Guide*.
1717

18+
**Example 2: To delete a namespace using namespace ARN**
19+
20+
The following ``delete-namespace`` example deletes a namespace using its ARN. ::
21+
22+
aws servicediscovery delete-namespace \
23+
--id arn:aws:servicediscovery:us-west-2:123456789012:namespace/ns-abcd1234xmpl5678
24+
25+
Output::
26+
27+
{
28+
"OperationId": "abcd1234-5678-90ab-cdef-xmpl12345678"
29+
}
30+
31+
For more information, see `Deleting an AWS Cloud Map namespace <https://docs.aws.amazon.com/cloud-map/latest/dg/deleting-namespaces.html>`__ in the *AWS Cloud Map Developer Guide*.
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
**To delete a service attribute**
1+
**Example 1: To delete a service attribute**
22

33
The following ``delete-service-attributes`` example deletes a service attribute with the key ``Port`` that is associated with the specified service. ::
44

55
aws servicediscovery delete-service-attributes \
6-
--service-id srv-e4anhexample0004 \
6+
--service-id srv-abcd1234xmpl5678 \
77
--attributes Port
88

99
This command produces no output.
1010

11-
For more information, see `Deleting namespaces <https://docs.aws.amazon.com/cloud-map/latest/dg/deleting-namespaces.html>`__ in the *AWS Cloud Map Developer Guide*.
11+
For more information, see `AWS Cloud Map services <https://docs.aws.amazon.com/cloud-map/latest/dg/working-with-services.html>`__ in the *AWS Cloud Map Developer Guide*.
12+
13+
**Example 2: To delete a service attribute using ARN**
14+
15+
The following ``delete-service-attributes`` example deletes a service attribute using the service ARN. Specifying the ARN is necessary for deleting attributes associated with services created in namespaces shared with your account. ::
16+
17+
aws servicediscovery delete-service-attributes \
18+
--service-id arn:aws:servicediscovery:us-west-2:123456789012:service/srv-abcd1234xmpl5678 \
19+
--attributes Port
20+
21+
This command produces no output.
22+
23+
For more information, see `AWS Cloud Map services <https://docs.aws.amazon.com/cloud-map/latest/dg/working-with-services.html>`__ and `Shared AWS Cloud Map namespaces <https://docs.aws.amazon.com/cloud-map/latest/dg/sharing-namespaces.html>`__ in the *AWS Cloud Map Developer Guide*.
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
**To delete a service**
1+
**Example 1: To delete a service**
22

33
The following ``delete-service`` example deletes a service. ::
44

55
aws servicediscovery delete-service \
6-
--id srv-p5zdwlg5uvvzjita
6+
--id srv-abcd1234xmpl5678
77

88
This command produces no output.
99

10-
For more information, see `Deleting services <https://docs.aws.amazon.com/cloud-map/latest/dg/deleting-services.html>`__ in the *AWS Cloud Map Developer Guide*.
10+
For more information, see `Deleting an AWS Cloud Map service <https://docs.aws.amazon.com/cloud-map/latest/dg/deleting-services.html>`__ in the *AWS Cloud Map Developer Guide*.
1111

12+
**Example 2: To delete a service using ARN**
13+
14+
The following ``delete-service`` example deletes a service using its ARN. ::
15+
16+
aws servicediscovery delete-service \
17+
--id arn:aws:servicediscovery:us-west-2:123456789012:service/srv-abcd1234xmpl5678
18+
19+
This command produces no output.
20+
21+
For more information, see `Deleting an AWS Cloud Map service <https://docs.aws.amazon.com/cloud-map/latest/dg/deleting-services.html>`__ in the *AWS Cloud Map Developer Guide*.

awscli/examples/servicediscovery/deregister-instance.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**To deregister a service instance**
1+
**Example 1: To deregister a service instance**
22

33
The following ``deregister-instance`` example deregisters a service instance. ::
44

@@ -12,7 +12,23 @@ Output::
1212
"OperationId": "4yejorelbukcjzpnr6tlmrghsjwpngf4-k98rnaiq"
1313
}
1414

15-
To confirm that the operation succeeded, you can run ``get-operation``. For more information, see `get-operation <https://docs.aws.amazon.com/cli/latest/reference/servicediscovery/get-operation.html>`__ .
15+
To confirm that the operation succeeded, you can run ``get-operation``. For more information, see `get-operation <https://docs.aws.amazon.com/cli/latest/reference/servicediscovery/get-operation.html>`__.
1616

1717
For more information, see `Deregistering service instances <https://docs.aws.amazon.com/cloud-map/latest/dg/deregistering-instances.html>`__ in the *AWS Cloud Map Developer Guide*.
1818

19+
**Example 2: To deregister a service instance using service ARN for shared namespaces**
20+
21+
The following ``deregister-instance`` example deregisters a service instance using a service ARN instead of service ID. Specifying an ARN is required when deregistering instances from services created in namespaces that are shared with your account. ::
22+
23+
aws servicediscovery deregister-instance \
24+
--service-id arn:aws:servicediscovery:us-west-2:123456789012:service/srv-p5zdwlg5uvvzjita \
25+
--instance-id web-server-01
26+
27+
Output::
28+
29+
{
30+
"OperationId": "gv4g5meo7ndmkqjrhpn39wk42xmpl"
31+
}
32+
33+
For more information, see `Shared AWS Cloud Map namespaces <https://docs.aws.amazon.com/cloud-map/latest/dg/sharing-namespaces.html>`__ and `Deregistering an AWS Cloud Map service instance <https://docs.aws.amazon.com/cloud-map/latest/dg/deregistering-instances.html>`__ in the *AWS Cloud Map Developer Guide*.
34+

awscli/examples/servicediscovery/discover-instances-revision.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**To discover the revision of an instance**
1+
**Example 1: To discover the revision of an instance**
22

33
The following ``discover-instances-revision`` example discovers the increasing revision of an instance. ::
44

@@ -13,3 +13,20 @@ Output::
1313
}
1414

1515
For more information, see `AWS Cloud Map service instances <https://docs.aws.amazon.com/cloud-map/latest/dg/working-with-instances.html>`__ in the *AWS Cloud Map Developer Guide*.
16+
17+
**Example 2: To discover the revision of instances from a specific owner account**
18+
19+
The following ``discover-instances-revision`` example discovers the revision of instances from a specific owner account. The owner-account parameter is necessary for instances in namespaces that are shared with your account. ::
20+
21+
aws servicediscovery discover-instances-revision \
22+
--namespace-name shared-namespace \
23+
--service-name shared-service \
24+
--owner-account 123456789111
25+
26+
Output::
27+
28+
{
29+
"InstancesRevision": 1234567890
30+
}
31+
32+
For more information, see `Shared AWS Cloud Map namespaces <https://docs.aws.amazon.com/cloud-map/latest/dg/sharing-namespaces.html>`__ and `AWS Cloud Map service instances <https://docs.aws.amazon.com/cloud-map/latest/dg/working-with-instances.html>`__ in the *AWS Cloud Map Developer Guide*.

awscli/examples/servicediscovery/discover-instances.rst

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**To discover registered instances**
1+
**Example 1: To discover registered instances**
22

33
The following ``discover-instances`` example discovers registered instances. ::
44

@@ -22,7 +22,37 @@ Output::
2222
"AWS_INSTANCE_PORT": "808"
2323
}
2424
}
25-
]
25+
],
26+
"InstancesRevision": 85648075627387284
2627
}
2728

2829
For more information, see `AWS Cloud Map service instances <https://docs.aws.amazon.com/cloud-map/latest/dg/working-with-instances.html>`__ in the *AWS Cloud Map Developer Guide*.
30+
31+
**Example 2: To discover instances from a specific owner account**
32+
33+
The following ``discover-instances`` example discovers registered instances from a specific owner account. This parameter is necessary to discover instances in namespaces that are shared with your account. ::
34+
35+
aws servicediscovery discover-instances \
36+
--namespace-name shared-namespace \
37+
--service-name shared-service \
38+
--owner-account 123456789111
39+
40+
Output::
41+
42+
{
43+
"Instances": [
44+
{
45+
"InstanceId": "shared-instance-1234",
46+
"NamespaceName": "shared-namespace",
47+
"ServiceName": "shared-service",
48+
"HealthStatus": "HEALTHY",
49+
"Attributes": {
50+
"AWS_INSTANCE_IPV4": "203.0.113.75",
51+
"AWS_INSTANCE_PORT": "80"
52+
}
53+
}
54+
],
55+
"InstancesRevision": 1234567890
56+
}
57+
58+
For more information, see `Shared AWS Cloud Map namespaces <https://docs.aws.amazon.com/cloud-map/latest/dg/sharing-namespaces.html>`__ and `AWS Cloud Map service instances <https://docs.aws.amazon.com/cloud-map/latest/dg/working-with-instances.html>`__ in the *AWS Cloud Map Developer Guide*.
Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**To get the details of an instance**
1+
**Example 1: To get the details of an instance**
22

33
The following ``get-instance`` example gets the attributes of a service. ::
44

@@ -8,17 +8,43 @@ The following ``get-instance`` example gets the attributes of a service. ::
88

99
Output::
1010

11-
{
12-
"Instances": {
11+
{
12+
"ResourceOwner": "123456789012",
13+
"Instance": {
1314
"Id": "arn:aws:servicediscovery:us-west-2:111122223333;:service/srv-e4anhexample0004",
1415
"Attributes": {
1516
"AWS_INSTANCE_IPV4": "192.0.2.44",
1617
"AWS_INSTANCE_PORT": "80",
1718
"color": "green",
1819
"region": "us-west-2",
1920
"stage": "beta"
20-
}
21+
},
22+
"CreatedByAccount": "123456789012"
2123
}
2224
}
2325

2426
For more information, see `AWS Cloud Map service instances <https://docs.aws.amazon.com/cloud-map/latest/dg/working-with-instances.html>`__ in the *AWS Cloud Map Developer Guide*.
27+
28+
**Example 2: To get the details of an instance using service ARN for shared namespaces**
29+
30+
The following ``get-instance`` example gets the attributes of an instance using a service ARN instead of service ID. Specifying an ARN is required when getting details of instances associated with namespaces that are shared with your account. The instance returned in this example was registered by account ``123456789111`` in a namespace owned by account ``123456789012``. ::
31+
32+
aws servicediscovery get-instance \
33+
--service-id arn:aws:servicediscovery:us-west-2:123456789012:service/srv-p5zdwlg5uvvzjita \
34+
--instance-id web-server-01
35+
36+
Output::
37+
38+
{
39+
"ResourceOwner": "123456789012",
40+
"Instance": {
41+
"Id": "web-server-01",
42+
"Attributes": {
43+
"AWS_INSTANCE_IPV4": "203.0.113.15",
44+
"AWS_INSTANCE_PORT": "80"
45+
},
46+
"CreatedByAccount": "123456789111"
47+
}
48+
}
49+
50+
For more information about cross-account namespace sharing, see `Shared AWS Cloud Map namespaces <https://docs.aws.amazon.com/cloud-map/latest/dg/sharing-namespaces.html>`__ in the *AWS Cloud Map Developer Guide*.

awscli/examples/servicediscovery/get-instances-health-status.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**To get the health status of instances associated with a service**
1+
**Example 1: To get the health status of instances associated with a service**
22

33
The following ``get-instances-health-status`` example gets the health status of instances associated with the specified service. ::
44

@@ -15,3 +15,21 @@ Output::
1515
}
1616

1717
For more information, see `AWS Cloud Map service instances <https://docs.aws.amazon.com/cloud-map/latest/dg/working-with-instances.html>`__ in the *AWS Cloud Map Developer Guide*.
18+
19+
**Example 2: To get the health status of instances using service ARN for shared namespaces**
20+
21+
The following ``get-instances-health-status`` example gets the health status of instances using a service ARN instead of service ID. Specifying an ARN is required when getting health status for instances associated with namespaces that are shared with the requester's account. ::
22+
23+
aws servicediscovery get-instances-health-status \
24+
--service-id arn:aws:servicediscovery:us-west-2:123456789012:service/srv-p5zdwlg5uvvzjita
25+
26+
Output::
27+
28+
{
29+
"Status": {
30+
"web-server-01": "HEALTHY",
31+
"web-server-02": "UNHEALTHY"
32+
}
33+
}
34+
35+
For more information, see `AWS Cloud Map service instances <https://docs.aws.amazon.com/cloud-map/latest/dg/working-with-instances.html>`__ and `Shared AWS Cloud Map namespaces <https://docs.aws.amazon.com/cloud-map/latest/dg/sharing-namespaces.html>`__ in the *AWS Cloud Map Developer Guide*.

0 commit comments

Comments
 (0)