

Sono disponibili altri esempi AWS SDK nel repository [AWS Doc SDK](https://github.com/awsdocs/aws-doc-sdk-examples) Examples. GitHub 

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Utilizzo `GetBucketLocation` con un AWS SDK o una CLI
<a name="s3_example_s3_GetBucketLocation_section"></a>

Gli esempi di codice seguenti mostrano come utilizzare `GetBucketLocation`.

------
#### [ CLI ]

**AWS CLI**  
Il comando seguente recupera il vincolo di posizione per un bucket denominato `amzn-s3-demo-bucket`, se esiste un vincolo.  

```
aws s3api get-bucket-location --bucket amzn-s3-demo-bucket
```
Output:  

```
{
    "LocationConstraint": "us-west-2"
}
```
+  Per i dettagli sull'API, consulta [GetBucketLocation AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/get-bucket-location.html)*Command Reference.* 

------
#### [ PowerShell ]

**Strumenti per PowerShell V4**  
**Esempio 1: questo comando restituisce il vincolo di posizione eventualmente presente per il bucket “amzn-s3-demo-bucket.**  

```
Get-S3BucketLocation -BucketName 'amzn-s3-demo-bucket'
```
**Output:**  

```
Value
-----
ap-south-1
```
+  Per i dettagli sull'API, vedere [GetBucketLocation](https://docs.aws.amazon.com/powershell/v4/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V4). 

**Strumenti per V5 PowerShell **  
**Esempio 1: questo comando restituisce il vincolo di posizione eventualmente presente per il bucket “amzn-s3-demo-bucket.**  

```
Get-S3BucketLocation -BucketName 'amzn-s3-demo-bucket'
```
**Output:**  

```
Value
-----
ap-south-1
```
+  Per i dettagli sull'API, vedere [GetBucketLocation](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

------
#### [ Rust ]

**SDK per Rust**  
 C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel [Repository di esempi di codice AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/rustv1/examples/s3#code-examples). 

```
async fn show_buckets(
    strict: bool,
    client: &Client,
    region: BucketLocationConstraint,
) -> Result<(), S3ExampleError> {
    let mut buckets = client.list_buckets().into_paginator().send();

    let mut num_buckets = 0;
    let mut in_region = 0;

    while let Some(Ok(output)) = buckets.next().await {
        for bucket in output.buckets() {
            num_buckets += 1;
            if strict {
                let r = client
                    .get_bucket_location()
                    .bucket(bucket.name().unwrap_or_default())
                    .send()
                    .await?;

                if r.location_constraint() == Some(&region) {
                    println!("{}", bucket.name().unwrap_or_default());
                    in_region += 1;
                }
            } else {
                println!("{}", bucket.name().unwrap_or_default());
            }
        }
    }

    println!();
    if strict {
        println!(
            "Found {} buckets in the {} region out of a total of {} buckets.",
            in_region, region, num_buckets
        );
    } else {
        println!("Found {} buckets in all regions.", num_buckets);
    }

    Ok(())
}
```
+  Per i dettagli sulle API, consulta la [GetBucketLocation](https://docs.rs/aws-sdk-s3/latest/aws_sdk_s3/client/struct.Client.html#method.get_bucket_location)guida di *riferimento all'API AWS SDK for Rust*. 

------