Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use DescribeEndpoint with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DescribeEndpoint with an AWS SDK or CLI

The following code examples show how to use DescribeEndpoint.

C++
SDK for C++
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

//! Describe the endpoint specific to the AWS account making the call. /*! \param endpointResult: String to receive the endpoint result. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::IoT::describeEndpoint(Aws::String &endpointResult, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::String endpoint; Aws::IoT::IoTClient iotClient(clientConfiguration); Aws::IoT::Model::DescribeEndpointRequest describeEndpointRequest; describeEndpointRequest.SetEndpointType( "iot:Data-ATS"); // Recommended endpoint type. Aws::IoT::Model::DescribeEndpointOutcome outcome = iotClient.DescribeEndpoint( describeEndpointRequest); if (outcome.IsSuccess()) { std::cout << "Successfully described endpoint." << std::endl; endpointResult = outcome.GetResult().GetEndpointAddress(); } else { std::cerr << "Error describing endpoint" << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
CLI
AWS CLI

Example 1: To get your current AWS endpoint

The following describe-endpoint example retrieves the default AWS endpoint to which all commands are applied.

aws iot describe-endpoint

Output:

{ "endpointAddress": "abc123defghijk.iot.us-west-2.amazonaws.com" }

For more information, see DescribeEndpoint in the AWS IoT Developer Guide.

Example 2: To get your ATS endpoint

The following describe-endpoint example retrieves the Amazon Trust Services (ATS) endpoint.

aws iot describe-endpoint \ --endpoint-type iot:Data-ATS

Output:

{ "endpointAddress": "abc123defghijk-ats.iot.us-west-2.amazonaws.com" }

For more information, see X.509 Certificates and AWS IoT in the AWS IoT Developer Guide.

Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

/** * Describes the endpoint of the IoT service asynchronously. * * @return A CompletableFuture containing the full endpoint URL. * * This method initiates an asynchronous request to describe the endpoint of the IoT service. * If the request is successful, it prints and returns the full endpoint URL. * If an exception occurs, it prints the error message. */ public String describeEndpoint() { CompletableFuture<DescribeEndpointResponse> future = getAsyncClient().describeEndpoint(DescribeEndpointRequest.builder().endpointType("iot:Data-ATS").build()); final String[] result = {null}; future.whenComplete((endpointResponse, ex) -> { if (endpointResponse != null) { String endpointUrl = endpointResponse.endpointAddress(); String exString = getValue(endpointUrl); String fullEndpoint = "https://" + exString + "-ats.iot.us-east-1.amazonaws.com"; System.out.println("Full Endpoint URL: " + fullEndpoint); result[0] = fullEndpoint; } else { Throwable cause = (ex instanceof CompletionException) ? ex.getCause() : ex; if (cause instanceof IotException) { System.err.println(((IotException) cause).awsErrorDetails().errorMessage()); } else { System.err.println("Unexpected error: " + cause.getMessage()); } } }); future.join(); return result[0]; }
Kotlin
SDK for Kotlin
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

suspend fun describeEndpoint(): String? { val request = DescribeEndpointRequest {} IotClient { region = "us-east-1" }.use { iotClient -> val endpointResponse = iotClient.describeEndpoint(request) val endpointUrl: String? = endpointResponse.endpointAddress val exString: String = getValue(endpointUrl) val fullEndpoint = "https://$exString-ats.iot.us-east-1.amazonaws.com" println("Full endpoint URL: $fullEndpoint") return fullEndpoint } }
Rust
SDK for Rust
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

async fn show_address(client: &Client, endpoint_type: &str) -> Result<(), Error> { let resp = client .describe_endpoint() .endpoint_type(endpoint_type) .send() .await?; println!("Endpoint address: {}", resp.endpoint_address.unwrap()); println!(); Ok(()) }
SDK for C++
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

//! Describe the endpoint specific to the AWS account making the call. /*! \param endpointResult: String to receive the endpoint result. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::IoT::describeEndpoint(Aws::String &endpointResult, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::String endpoint; Aws::IoT::IoTClient iotClient(clientConfiguration); Aws::IoT::Model::DescribeEndpointRequest describeEndpointRequest; describeEndpointRequest.SetEndpointType( "iot:Data-ATS"); // Recommended endpoint type. Aws::IoT::Model::DescribeEndpointOutcome outcome = iotClient.DescribeEndpoint( describeEndpointRequest); if (outcome.IsSuccess()) { std::cout << "Successfully described endpoint." << std::endl; endpointResult = outcome.GetResult().GetEndpointAddress(); } else { std::cerr << "Error describing endpoint" << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
PrivacySite termsCookie preferences
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.