There are more AWS SDK examples available in the AWS Doc SDK Examples
Use ListHostedZones
with an AWS SDK or CLI
The following code examples show how to use ListHostedZones
.
- CLI
-
- AWS CLI
-
To list the hosted zones associated with the current AWS account
The following
list-hosted-zones
command lists summary information about the first 100 hosted zones that are associated with the current AWS account.:aws route53 list-hosted-zones
If you have more than 100 hosted zones, or if you want to list them in groups smaller than 100, include the
--max-items
parameter. For example, to list hosted zones one at a time, use the following command:aws route53 list-hosted-zones --max-items
1
To view information about the next hosted zone, take the value of
NextToken
from the response to the previous command, and include it in the--starting-token
parameter, for example:aws route53 list-hosted-zones --max-items
1
--starting-tokenZ3M3LMPEXAMPLE
-
For API details, see ListHostedZones
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell
-
Example 1: Outputs all of your public and private hosted zones.
Get-R53HostedZoneList
Example 2: Outputs all of the hosted zones that are associated with the reusable delegation set that has the ID NZ8X2CISAMPLE
Get-R53HostedZoneList -DelegationSetId NZ8X2CISAMPLE
-
For API details, see ListHostedZones in AWS Tools for PowerShell Cmdlet Reference.
-
- 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_host_info(client: &aws_sdk_route53::Client) -> Result<(), aws_sdk_route53::Error> { let hosted_zone_count = client.get_hosted_zone_count().send().await?; println!( "Number of hosted zones in region : {}", hosted_zone_count.hosted_zone_count(), ); let hosted_zones = client.list_hosted_zones().send().await?; println!("Zones:"); for hz in hosted_zones.hosted_zones() { let zone_name = hz.name(); let zone_id = hz.id(); println!(" ID : {}", zone_id); println!(" Name : {}", zone_name); println!(); } Ok(()) }
-
For API details, see ListHostedZones
in AWS SDK for Rust API reference.
-