Storage Gateway examples using Amazon CLI - Amazon Command Line Interface
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).

This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.

Storage Gateway examples using Amazon CLI

The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with Storage Gateway.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use describe-gateway-information.

Amazon CLI

To describe a gateway

The following describe-gateway-information command returns metadata about the specified gateway. To specify which gateway to describe, use the Amazon Resource Name (ARN) of the gateway in the command.

This examples specifies a gateway with the id sgw-12A3456B in account 123456789012:

aws storagegateway describe-gateway-information --gateway-arn "arn:aws:storagegateway:us-west-2:123456789012:gateway/sgw-12A3456B"

This command outputs a JSON block that contains metadata about about the gateway such as its name, network interfaces, configured time zone, and the state (whether the gateway is running or not).

The following code example shows how to use list-file-shares.

Amazon CLI

To list file shares

The following command-name example lists the available widgets in your Amazon account.

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

Output:

{ "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 }

For more information, see ListFileShares in the Amazon Storage Gateway Service API Reference.

  • For API details, see ListFileShares in Amazon CLI Command Reference.

The following code example shows how to use list-gateways.

Amazon CLI

To list gateways for an account

The following list-gateways command lists all the gateways defined for an account:

aws storagegateway list-gateways

This command outputs a JSON block that contains a list of gateway Amazon Resource Names (ARNs).

  • For API details, see ListGateways in Amazon CLI Command Reference.

The following code example shows how to use list-volumes.

Amazon CLI

To list the volumes configured for a gateway

The following list-volumes command returns a list of volumes configured for the specified gateway. To specify which gateway to describe, use the Amazon Resource Name (ARN) of the gateway in the command.

This examples specifies a gateway with the id sgw-12A3456B in account 123456789012:

aws storagegateway list-volumes --gateway-arn "arn:aws:storagegateway:us-west-2:123456789012:gateway/sgw-12A3456B"

This command outputs a JSON block that a list of volumes that includes the type and ARN for each volume.

  • For API details, see ListVolumes in Amazon CLI Command Reference.

The following code example shows how to use refresh-cache.

Amazon CLI

To refresh the file share cache

The following refresh-cache example refreshes the cache for the specified file share.

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

Output:

{ "FileShareARN": "arn:aws:storagegateway:us-east-1:111122223333:share/share-2FA12345", "NotificationId": "4954d4b1-abcd-ef01-1234-97950a7d3483" }

For more information, see ListFileShares in the Amazon Storage Gateway Service API Reference.

  • For API details, see RefreshCache in Amazon CLI Command Reference.