

# AWS CLI を使用した Storage Gateway の例
<a name="cli_storage-gateway_code_examples"></a>

次のコード例は、Storage Gateway で AWS Command Line Interface を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。

*アクション*はより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。

**Topics**
+ [アクション](#actions)

## アクション
<a name="actions"></a>

### `describe-gateway-information`
<a name="storage-gateway_DescribeGatewayInformation_cli_topic"></a>

次のコード例は、`describe-gateway-information` を使用する方法を示しています。

**AWS CLI**  
**ゲートウェイを記述するには**  
次の `describe-gateway-information` コマンドは、指定されたゲートウェイに関するメタデータを返します。記述するゲートウェイを指定するには、コマンドでゲートウェイの Amazon リソースネーム (ARN) を使用します。  
この例では、 アカウント `123456789012` の ID `sgw-12A3456B` を持つゲートウェイを指定します。  

```
aws storagegateway describe-gateway-information --gateway-arn "arn:aws:storagegateway:us-west-2:123456789012:gateway/sgw-12A3456B"
```
このコマンドは、名前、ネットワークインターフェイス、設定したタイムゾーン、および状態 (ゲートウェイが実行中かどうか) など、ゲートウェイに関するメタデータを含む JSON ブロックを出力します。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DescribeGatewayInformation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/storagegateway/describe-gateway-information.html)」を参照してください。

### `list-file-shares`
<a name="storage-gateway_ListFileShares_cli_topic"></a>

次のコード例は、`list-file-shares` を使用する方法を示しています。

**AWS CLI**  
**ファイル共有を一覧表示するには**  
次の `command-name` の例では、AWS アカウントで使用可能なウィジェットを一覧表示します。  

```
aws storagegateway list-file-shares \
    --gateway-arn arn:aws:storagegateway:us-east-1:209870788375:gateway/sgw-FB02E292
```
出力:  

```
{
    "FileShareInfoList": [
        {
            "FileShareType": "NFS",
            "FileShareARN": "arn:aws:storagegateway:us-east-1:111122223333:share/share-2FA12345",
            "FileShareId": "share-2FA12345",
            "FileShareStatus": "AVAILABLE",
            "GatewayARN": "arn:aws:storagegateway:us-east-1:111122223333:gateway/sgw-FB0AAAAA"
        }
    ],
    "Marker": null
}
```
詳細については、「*AWS Storage Gateway Service API Reference*」の「[ListFileShares](https://docs.aws.amazon.com/storagegateway/latest/APIReference/API_ListFileShares.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListFileShares](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/storagegateway/list-file-shares.html)」を参照してください。

### `list-gateways`
<a name="storage-gateway_ListGateways_cli_topic"></a>

次のコード例は、`list-gateways` を使用する方法を示しています。

**AWS CLI**  
**アカウントのゲートウェイを一覧表示するには**  
次の `list-gateways` コマンドは、アカウントに定義されているすべてのゲートウェイを一覧表示します。  

```
aws storagegateway list-gateways
```
このコマンドは、ゲートウェイの Amazon リソースネーム (ARN) のリストを含む JSON ブロックを出力します。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListGateways](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/storagegateway/list-gateways.html)」を参照してください。

### `list-volumes`
<a name="storage-gateway_ListVolumes_cli_topic"></a>

次のコード例は、`list-volumes` を使用する方法を示しています。

**AWS CLI**  
**ゲートウェイ用に設定されたボリュームを一覧表示するには**  
次の `list-volumes` コマンドは、指定されたゲートウェイ用に設定されたボリュームのリストを返します。記述するゲートウェイを指定するには、コマンドでゲートウェイの Amazon リソースネーム (ARN) を使用します。  
この例では、アカウント `123456789012` の ID `sgw-12A3456B` を持つゲートウェイを指定します。  

```
aws storagegateway list-volumes --gateway-arn "arn:aws:storagegateway:us-west-2:123456789012:gateway/sgw-12A3456B"
```
このコマンドは、各ボリュームのタイプと ARN を含むボリュームのリストである JSON ブロックを出力します。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListVolumes](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/storagegateway/list-volumes.html)」を参照してください。

### `refresh-cache`
<a name="storage-gateway_RefreshCache_cli_topic"></a>

次のコード例は、`refresh-cache` を使用する方法を示しています。

**AWS CLI**  
**ファイル共有キャッシュを更新するには**  
次の `refresh-cache` の例では、指定されたファイル共有のキャッシュを更新します。  

```
aws storagegateway refresh-cache \
    --file-share-arn arn:aws:storagegateway:us-east-1:111122223333:share/share-2FA12345
```
出力:  

```
{
    "FileShareARN": "arn:aws:storagegateway:us-east-1:111122223333:share/share-2FA12345",
    "NotificationId": "4954d4b1-abcd-ef01-1234-97950a7d3483"
}
```
詳細については、「*AWS Storage Gateway Service API Reference*」の「[ListFileShares](https://docs.aws.amazon.com/storagegateway/latest/APIReference/API_RefreshCache.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[RefreshCache](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/storagegateway/refresh-cache.html)」を参照してください。