Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use ListDomains
with an Amazon SDK or CLI
The following code examples show how to use ListDomains
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code example:
- .NET
-
- Amazon SDK for .NET
-
/// <summary>
/// List the domains for the account.
/// </summary>
/// <returns>A collection of domain summary records.</returns>
public async Task<List<DomainSummary>> ListDomains()
{
var results = new List<DomainSummary>();
var paginateDomains = _amazonRoute53Domains.Paginators.ListDomains(
new ListDomainsRequest());
// Get the entire list using the paginator.
await foreach (var domain in paginateDomains.Domains)
{
results.Add(domain);
}
return results;
}
- CLI
-
- Amazon CLI
-
To list the domains that are registered with the current Amazon account
The following list-domains
command lists summary information about the domains that are registered with the current Amazon account.
This command runs only in the us-east-1
Region. If your default region is set to us-east-1
, you can omit the region
parameter.
aws route53domains list-domains
--region us-east-1
Output:
{
"Domains": [
{
"DomainName": "example.com",
"AutoRenew": true,
"TransferLock": true,
"Expiry": 1602712345.0
},
{
"DomainName": "example.net",
"AutoRenew": true,
"TransferLock": true,
"Expiry": 1602723456.0
},
{
"DomainName": "example.org",
"AutoRenew": true,
"TransferLock": true,
"Expiry": 1602734567.0
}
]
}
- Java
-
- SDK for Java 2.x
-
public static void listDomains(Route53DomainsClient route53DomainsClient) {
try {
ListDomainsIterable listRes = route53DomainsClient.listDomainsPaginator();
listRes.stream()
.flatMap(r -> r.domains().stream())
.forEach(content -> System.out.println("The domain name is " + content.domainName()));
} catch (Route53Exception e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
- Kotlin
-
- SDK for Kotlin
-
suspend fun listDomains() {
Route53DomainsClient { region = "us-east-1" }.use { route53DomainsClient ->
route53DomainsClient
.listDomainsPaginated(ListDomainsRequest {})
.transform { it.domains?.forEach { obj -> emit(obj) } }
.collect { content ->
println("The domain name is ${content.domainName}")
}
}
}
For a complete list of Amazon SDK developer guides and code examples, see
Using Route 53 with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.