Getting an Activation Key for Your Gateway - AWS Storage Gateway

Getting an Activation Key for Your Gateway

To get an activation key for your gateway, you make a web request to the gateway VM and it returns a redirect that contains the activation key. This activation key is passed as one of the parameters to the ActivateGateway API action to specify the configuration of your gateway. The request you make to the gateway VM contains the AWS Region in which activation occurs.

The URL returned by the redirect in the response contains a query string parameter called activationkey. This query string parameter is your activation key. The format of the query string looks like the following: http://gateway_ip_address/?activationRegion=activation_region.

Linux command line interface (CLI)

The following example shows you how to use the Linux CLI to get the activation key.

curl 'ec2_instance_ip_address/?activationRegion=activation_region&no_redirect'

Microsoft Windows PowerShell

The following example shows you how to use Microsoft Windows PowerShell to fetch the HTTP response, parse HTTP headers, and get the activation key.

function Get-ActivationKey { [CmdletBinding()] Param( [parameter(Mandatory=$true)][string]$IpAddress, [parameter(Mandatory=$true)][string]$ActivationRegion ) PROCESS { $request = Invoke-WebRequest -UseBasicParsing -Uri "http://$IpAddress/?activationRegion=$ActivationRegion" -MaximumRedirection 0 -ErrorAction SilentlyContinue if ($request) { $activationKeyParam = $request.Headers.Location | Select-String -Pattern "activationKey=([A-Z0-9-]+)" $activationKeyParam.Matches.Value.Split("=")[1] } } }