
はじめてのAWS Snowcone – (10) CLIでSnowconeデバイスを操作する
この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
しばたです。
本記事ではCLIを使ったSnowconeデバイスの各種操作方法を解説します。
目次
- はじめてのAWS Snowcone - (1) はじめに
- はじめてのAWS Snowcone - (2) 事前準備から注文まで
- はじめてのAWS Snowcone - (3) AWS OpsHub for Snow Family のインストール
- はじめてのAWS Snowcone - (4) デバイスの配送から受け取りまで
- はじめてのAWS Snowcone - (5) ネットワーク設定とロック解除
- はじめてのAWS Snowcone - (6) NFSサーバーのセットアップ
- はじめてのAWS Snowcone - (7) EC2のセットアップ
- はじめてのAWS Snowcone - (8) AWS DataSync Agentのセットアップ
- はじめてのAWS Snowcone - (9) その他機能、デバイスの停止
- はじめてのAWS Snowcone - (10) CLIでSnowconeデバイスを操作する
- はじめてのAWS Snowcone - (11) デバイスの返却からS3インポートまで
- はじめてのAWS Snowcone - (12) Snowconeジョブの物流と請求について
免責事項
CLI操作の基本
AWS SnowconeおよびAWS Snowball Edgeデバイスを操作するCLIツールにSnowball Edge Clinetがあります。
Snowball Edge Clinetを使うことでデバイスの情報を取得したり、デバイスに関連する各種操作を行うことができます。
加えてデバイスからダウンロードできる「アクセスキー」を使うことでAWS CLIからデバイス内部のEC2を操作することもできます。
本記事では両者それぞれの実行例を紹介します。
検証環境
本記事の検証環境は私の開発機(Windows 10)を使い、PowerShell 7.2.1上でコマンドを実行します。
Snowball Edge Clinetのバージョンはv.1.2.0、AWS CLIのバージョンはv2.4.7となります。
1. Snowball Edge Clinetでデバイスを操作する
1-1. Snowball Edge Clinetのインストール
Snowball Edge Clinetのインストール手順は以前解説してるので以下の記事をご覧ください。
1-2. 初期設定およびプロファイル
Snowball Edge Clinetの初期設定(デフォルトプロファイル指定)はAWS CLIと同様にsnowballEdge configureコマンドを使うと対話的に行えます。
# snowballEdge configure コマンドでデフォルトプロファイルを設定可能 (個人的にはあまりお勧めしない)
C:\> snowballEdge configure
Configuration will stored at C:\Users\username\.aws\snowball\config\snowball-edge.config
Snowball Edge Manifest Path: C:\temp\snowcone-device_manifest.bin
Unlock Code: xxxxx-xxxxx-xxxxx-xxxxx-xxxxx
Default Endpoint: https://192.168.9.150
この操作により~/.aws/snowball/config/snowball-edge.configにある設定ファイルにdefaultプロファイルが作成されます。
snowball-edge.configファイルはAWS CLIの設定ファイルとは異なりJSON形式ですがエディタで直接編集しても構いません。

(マニフェストファイルも同じフォルダに保存される模様)
ちなみにAWS OpsHubの初回ログイン時に保存したプロファイルも同じsnowball-edge.configファイルに保存されます。
このためsnowballEdge configureを実行せずに各コマンドの--profileパラメーターを指定してやることでもコマンドは実行可能です。
AWS CLIでもそうですが、個人的にはdefaultプロファイルを使うのはお勧めしたくないので本記事では--profileパラメーターを明示する形でコマンド例を紹介します。
1-3. デバイスの状態取得
Snowconeデバイスの情報を取得するにはsnowballEdge describe-deviceコマンドを使います。
デバイスのロック状態や物理NICの情報を取得できます。
ちょっと厄介なのがデバイスのロック解除前後で取得できる情報に差がある点となります。
# ロック時のデバイス情報
C:\> snowballEdge describe-device --profile my-first-snowcone
{
  "DeviceId" : "xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "UnlockStatus" : {
    "State" : "LOCKED"
  },
  "PhysicalNetworkInterfaces" : [ {
    "PhysicalConnectorType" : "RJ45_2",
    "IpAddressAssignment" : "STATIC",
    "IpAddress" : "192.168.20.2",
    "Netmask" : "255.255.255.0",
    "DefaultGateway" : "192.168.9.1",
    "MacAddress" : "8c:0f:6f:xx:xx:xx"
  }, {
    "PhysicalConnectorType" : "RJ45",
    "IpAddressAssignment" : "STATIC",
    "IpAddress" : "192.168.9.150",
    "Netmask" : "255.255.255.0",
    "DefaultGateway" : "192.168.9.1",
    "MacAddress" : "8c:0f:6f:xx:xx:xx"
  }, {
    "PhysicalConnectorType" : "WIFI",
    "IpAddressAssignment" : "STATIC",
    "IpAddress" : "0.0.0.0",
    "Netmask" : "0.0.0.0",
    "DefaultGateway" : "192.168.9.1",
    "MacAddress" : ""
  } ]
}
# ロック解除後のデバイス情報 : 物理NICIDやリソース利用状況が追加で取得可能になる
C:\> snowballEdge describe-device --profile my-first-snowcone
{
  "DeviceId" : "xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "UnlockStatus" : {
    "State" : "UNLOCKED"
  },
  "ActiveNetworkInterface" : {
    "IpAddress" : "192.168.9.150"
  },
  "PhysicalNetworkInterfaces" : [ {
    "PhysicalNetworkInterfaceId" : "s.ni-842025a469b4329e5",
    "PhysicalConnectorType" : "RJ45",
    "IpAddressAssignment" : "STATIC",
    "IpAddress" : "192.168.9.150",
    "Netmask" : "255.255.255.0",
    "DefaultGateway" : "192.168.9.1",
    "MacAddress" : "8c:0f:6f:xx:xx:xx"
  }, {
    "PhysicalNetworkInterfaceId" : "s.ni-88cabc27426d3c6e7",
    "PhysicalConnectorType" : "RJ45_2",
    "IpAddressAssignment" : "STATIC",
    "IpAddress" : "192.168.20.2",
    "Netmask" : "255.255.255.0",
    "DefaultGateway" : "192.168.9.1",
    "MacAddress" : "8c:0f:6f:xx:xx:xx"
  } ],
  "DeviceCapacities" : [ {
    "Name" : "HDD Storage",
    "Unit" : "Byte",
    "Total" : 158472601600,
    "Used" : 2147483648,
    "Available" : 156325117952
  }, {
    "Name" : "SSD Storage",
    "Unit" : "Byte",
    "Total" : 0,
    "Used" : 0,
    "Available" : 0
  }, {
    "Name" : "vCPU",
    "Unit" : "Number",
    "Total" : 3,
    "Used" : 1,
    "Available" : 2
  }, {
    "Name" : "Memory",
    "Unit" : "Byte",
    "Total" : 5368709120,
    "Used" : 1073741824,
    "Available" : 4294967296
  }, {
    "Name" : "GPU",
    "Unit" : "Number",
    "Total" : 0,
    "Used" : 0,
    "Available" : 0
  } ],
  "DeviceType" : "SNC1_HDD"
}
1-4. デバイスのロック解除
デバイスのロックを解除するにはsnowballEdge unlock-deviceコマンドを使います。
このコマンドは直ちに終了し、デバイスのロック状態を取得するにはsnowballEdge describe-deviceを使ってください。
# デバイスのロック解除
C:\> snowballEdge unlock-device --profile my-first-snowcone
Your Snowball Edge device is unlocking. You may determine the unlock state of your device using the describe-device command. Your Snowball Edge device will be available for use when it is in the UNLOCKED state.
# ロック状態だけ取りたい場合
C:\> snowballEdge describe-device --profile my-first-snowcone | ConvertFrom-Json | ForEach-Object { $_.UnlockStatus.State }
UNLOCKING
1-5. デバイスで利用可能なサービスの情報を取得する
デバイスで利用可能なサービスはnowballEdge list-servicesコマンドで取得できます。
Snowconeであれば通常ec2とnfsだけになるはずです。
# サービス一覧の取得
C:\> snowballEdge list-services --profile my-first-snowcone
{
  "ServiceIds" : [ "ec2", "nfs" ]
}
各サービスの詳細はsnowballEdge describe-serviceコマンドで取得できます。
# NFSの情報取得
C:\> snowballEdge describe-service --service-id nfs --profile my-first-snowcone
{
  "ServiceId" : "nfs",
  "Status" : {
    "State" : "DEACTIVATED"
  }
}
# EC2の情報取得
C:\> snowballEdge describe-service --service-id ec2 --profile my-first-snowcone
{
  "ServiceId" : "ec2",
  "Status" : {
    "State" : "ACTIVE"
  },
  "ServiceCapacities" : [ {
    "Name" : "AMI Snapshot Storage",
    "Unit" : "Byte",
    "Total" : 156586164224,
    "Used" : 0,
    "Available" : 132963844096
  }, {
    "Name" : "vCPU",
    "Unit" : "Number",
    "Total" : 3,
    "Used" : 2,
    "Available" : 1
  }, {
    "Name" : "Memory",
    "Unit" : "Byte",
    "Total" : 5368709120,
    "Used" : 3221225472,
    "Available" : 2147483648
  }, {
    "Name" : "GPU",
    "Unit" : "Number",
    "Total" : 0,
    "Used" : 0,
    "Available" : 0
  }, {
    "Name" : "Capacity Optimized HDD (sbg1)",
    "Unit" : "Byte",
    "Total" : 156586164224,
    "Used" : 23622320128,
    "Available" : 132963844096
  }, {
    "Name" : "Performance Optimized SSD (sbp1)",
    "Unit" : "Byte",
    "Total" : 0,
    "Used" : 0,
    "Available" : 0
  } ],
  "Endpoints" : [ {
    "Protocol" : "http",
    "Port" : 8008,
    "Host" : "192.168.9.150"
  }, {
    "Protocol" : "https",
    "Port" : 8243,
    "Host" : "192.168.9.150",
    "CertificateAssociation" : {
      "CertificateArn" : "arn:aws:snowball-device:::certificate/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
  } ]
}
1-6. デバイスで利用可能なサービスを開始・終了する
SnowconeではNFSのみ対象です。
NFSサーバーを有効にしたい場合はsnowballEdge start-serviceコマンドを使います。
逆にNFSサーバーを停止したい場合はsnowballEdge stop-serviceコマンドを使います。
# NFSサーバーを有効にする場合
C:\> snowballEdge start-service --service-id nfs `
  --service-configuration 'AllowedHosts=192.168.9.0/24,192.168.10.0/24' `
  --virtual-network-interface-arns 'arn:aws:snowball-device:::interface/s.ni-8503ebc56d3a3afd6' `
  --profile my-first-snowcone
Starting the service on your Snowball Edge. You can determine the status of the service using the describe-service command.
# NFSサーバーを停止する場合
C:\> snowballEdge stop-service --service-id nfs --profile my-first-snowcone
Stopping the service on your Snowball Edge. You can determine the status of the service using the describe-service command.
# ちなみにEC2は停止できません
C:\> snowballEdge stop-service --service-id ec2 --profile my-first-snowcone
UnsupportedOperationException - null (Service: AWSSnowballDevice; Status Code: 400; Error Code: UnsupportedOperationException; Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; Proxy: null)
1-7. 仮想NIC(VNI)関連
VNIを作成するにはsnowballEdge create-virtual-network-interfaceコマンドを使います。
作成済みVNIの参照はsnowballEdge describe-virtual-network-interfaces、更新はsnowballEdge update-virtual-network-interface、削除はsnowballEdge delete-virtual-network-interfaceコマンドを使います。
基本的には追加と削除だけ覚えておけば大丈夫な気がします。
# VNIを作成
C:\> snowballEdge create-virtual-network-interface `
     --physical-network-interface-id s.ni-842025a469b4329e5 `
     --ip-address-assignment DHCP `
     --profile my-first-snowcone
{
  "VirtualNetworkInterface" : {
    "VirtualNetworkInterfaceArn" : "arn:aws:snowball-device:::interface/s.ni-8170e24078093aeb1",
    "PhysicalNetworkInterfaceId" : "s.ni-842025a469b4329e5",
    "IpAddressAssignment" : "DHCP",
    "IpAddress" : "192.168.9.164",
    "Netmask" : "255.255.255.0",
    "DefaultGateway" : "192.168.9.1",
    "MacAddress" : "d6:e8:50:0b:da:fb"
  }
}
# VNIを削除
C:\> snowballEdge delete-virtual-network-interface `
    --virtual-network-interface-arn "arn:aws:snowball-device:::interface/s.ni-8170e24078093aeb1" `
    --profile my-first-snowcone
The virtual network interface has been deleted from your Snowball Edge. You can determine the virtual network interfaces available on your Snowball Edge using the describe-virtual-network-interfaces command.
1-8. ダイレクトNIC(DNI)関連
DNI関連のコマンドもVNIと同様にsnowballEdge create-direct-network-interface、snowballEdge describe-direct-network-interfaces、snowballEdge update-direct-network-interface、snowballEdge delete-direct-network-interfaceコマンドがあります。
DNIに関してはコマンドでしか設定できません。
詳細はこちらの記事をご覧ください。
1-9. デバイスの更新チェック
デバイスの更新チェックにはsnowballEdge check-for-updatesコマンドを使います。
このコマンドで更新が見つかった場合はsnowballEdge download-updatesコマンドおよびsnowballEdge install-updatesコマンドを使い更新作業を行うそうです。
(今回は更新が無いため試せませんでした...)
# デバイスの更新チェック
C:\> snowballEdge check-for-updates --profile my-first-snowcone
{
  "InstalledVersion" : "111",
  "LatestVersion" : "NA"
}
また、snowballEdge configure-auto-update-strategyコマンドを使うとデバイスの基本設定にある「自動更新」の方式を変更できます。
# snowballEdge configure-auto-update-strategy コマンドで自動更新の方式を変更
C:\> snowballEdge configure-auto-update-strategy `
    --auto-check true --auto-check-frequency "0 0 * * SUN" `
    --auto-download true --auto-download-frequency "0 1 * * SUN"`
    --auto-install false `
    --auto-reboot false `
    --profile my-first-snowcone
Successfully configured auto update strategy. Run describe-auto-update-strategies for additional information.
# snowballEdge describe-auto-update-strategies コマンドで現在の設定を表示
C:\> snowballEdge describe-auto-update-strategies --profile my-first-snowcone
{
  "AutoUpdateStrategies" : [ {
    "AutoCheck" : true,
    "AutoCheckFrequency" : "0 0 * * SUN",
    "AutoDownload" : true,
    "AutoDownloadFrequency" : "0 1 * * SUN",
    "AutoInstall" : false,
    "AutoReboot" : false
  } ]
}
1-10. デバイスの再起動
Snowconeデバイスを再起動するにはsnowballEdge reboot-deviceコマンドを使います。
なお、外部からデバイスをシャットダウンするコマンドは存在しません。
# デバイスを再起動する
C:\> snowballEdge reboot-device --profile my-first-snowcone
Rebooting device now.
1-11. タイムサーバーの設定
デバイスで使用するNTPサーバーの設定はsnowballEdge update-time-serversコマンドで行います。
# タイムサーバーの更新
C:\> snowballEdge update-time-servers time.google.com --profile my-first-snowcone
Updating time servers now.
# 現在使用しているタイムサーバーの取得
C:\> snowballEdge describe-time-sources --profile my-first-snowcone
{
  "Sources" : [ {
    "Address" : "216.239.35.4",
    "State" : "CURRENT",
    "Type" : "SERVER",
    "Stratum" : 1
  } ]
}
1-12. デバイスの証明書情報を取得する
snowballEdge list-certificatesおよびsnowballEdge get-certificateコマンドを使うとデバイスに設定されている証明書の情報を取得できます。
# デバイスの証明書一覧を取得
C:\> snowballEdge list-certificates --profile my-first-snowcone
{
  "Certificates" : [ {
    "CertificateArn" : "arn:aws:snowball-device:::certificate/xxxxxxxxxxxxxxxxxxxxxxxx",
    "SubjectAlternativeNames" : [ "192.168.9.150" ]
  } ]
}
# 個別の証明書を取得
C:\> snowballEdge get-certificate --certificate-arn "arn:aws:snowball-device:::certificate/xxxxxxxxxxxxxxxxxxxxxxxx" `
    --profile my-first-snowcone
-----BEGIN CERTIFICATE-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-----END CERTIFICATE-----
1-13. デバイス検証用QRコードを取得する
snowballEdge get-app-qr-codeコマンドを使うと、Snow Familyデバイスの改ざん検知のためのデバイス検証アプリ(Android Appのみ)で使うQRコードを出力できます。
# QRコードの取得
C:\> snowballEdge get-app-qr-code --output-file c:\temp\qr-code.png --profile my-first-snowcone
QR code is saved to c:\temp\qr-code.png
この機能の詳細については以下のドキュメントをご覧ください。
1-14. デバイスのログを取得する
主にAWSサポート提出用にデバイスのログを取得することができます。
snowballEdge list-logsおよびsnowballEdge get-logコマンドを使います。
# ログファイルの一覧を取得
C:\> snowballEdge list-logs --profile my-first-snowcone
{
  "Logs" : [ {
    "LogArn" : "arn:aws:snowball-device:::log/ec2-service-xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "LogType" : "SUPPORT",
    "ServiceId" : "ec2",
    "EstimatedSizeBytes" : 7854004
  }, 
    "LogArn" : "arn:aws:snowball-device:::log/snowcone-updater-cmb-xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "LogType" : "SUPPORT",
    "ServiceId" : "snowball-device",
    "EstimatedSizeBytes" : 277998
  } ]
}
# カレントディレクトリにログファイルを保存
C:\temp> snowballEdge get-log --log-arn "arn:aws:snowball-device:::log/snowcone-updater-cmb-xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" `
    --profile my-first-snowcone
Logs are being saved to C:\temp\snowball-edge-logs-1640624373681.zip
1-15. ローカルデバッグを有効にする
AWSサポートによるデバイスに対する直接調査のためにローカルデバッグを有効にすることができます。
snowballEdge enable-local-aws-operator-debuggingコマンドを使うとSnowconeデバイスのエンドポイントでSSHポートが解放されます。
ただ、一般ユーザーは認証情報を持っていないためポートが空いても特に何もできません...
snowballEdge disable-local-aws-operator-debuggingコマンドでローカルデバッグを無効にできます。
# ローカルデバッグを有効にする
C:\> snowballEdge enable-local-aws-operator-debugging --profile my-first-snowcone
Enabled device for local AWS operator debugging.
# ローカルデバッグを無効にする
C:\> snowballEdge disable-local-aws-operator-debugging --profile my-first-snowcone
Disabled device for local AWS operator debugging.
1-16. デバイスで利用可能な「機能」を確認する
snowballEdge describe-featuresコマンドを使うとデバイスで利用可能な機能を確認できます。
現状SnowconeではRemoteManagementStateしか対象でない様であまり使いどころがない感じです。
(デバイスをクラスターで注文するとまた違うのかもしれません...)
# バイスで利用可能な「機能」を確認する
C:\> snowballEdge describe-features --profile my-first-snowcone
{
  "RemoteManagementState" : "NOT_INSTALLED"
}
1-17. アクセスキーを取得する
次節で使うアクセスキーを取得するにはsnowballEdge list-access-keysおよびsnowballEdge get-secret-access-keysコマンドを使います。
# アクセスキーの一覧を取得
C:\> snowballEdge list-access-keys --profile my-first-snowcone
{
  "AccessKeyIds" : [ "AKIxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ]
}
# 各シークレットキーを取得
C:\> snowballEdge get-secret-access-key --access-key-id AKIxxxxxxxxxxxxxxxxxxxxxxxxxxxx `
    --profile my-first-snowcone
[snowballEdge]
aws_access_key_id = AKIxxxxxxxxxxxxxxxxxxxxxxxxxxxx
aws_secret_access_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2. AWS CLIでSnowcone内部のEC2を操作する
Snowcone内部のEC2はAWS CLIから操作することができます。
デバイスからダウンロードできるアクセスキーを指定のうえ、CLIのエンドポイントをデバイスのIPにすることで実現できます。
なお、AWS CLIのインストール手順は割愛します。
2-1. プロファイル設定
本記事ではダウンロードしたアクセスキーをsnowconeという名前のプロファイルに保存して利用します。
~/.aws/credentialおよび~/.aws/configを以下の様に設定しています。
[snowcone]
aws_access_key_id=AKIxxxxxxxxxxxxxxxxxxxxxxxxxxxx   # デバイスよりダウンロードしたアクセスキーを設定
aws_secret_access_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx # デバイスよりダウンロードしたシークレットキーを設定
~/.aws/configには既定のリージョンを設定。
[profile snowcone]
region = ap-northeast-1
cli_pager = 
2-2. エンドポイントの取得
AWS CLI用エンドポイントはSnowball Edge ClientのsnowballEdge describe-service --service-id ec2コマンドから取得できます。
今回の環境では
- HTTP : http://"デバイスのIP":8008
- HTTPS : https://"デバイスのIP":8243
となりますが、HTTPSの方はSSLの検証エラー[1]となるのでHTTPのエンドポイントを使います。
AWS CLIの各コマンドに--endpoint-url http://"デバイスのIP":8008パラメーターを追加することでSnowconeデバイスに対してコマンドを発行する形となります。
2-3. AMIの取得
AMIの取得はaws ec2 describe-imagesコマンドを使います。
AMIのIDにs.が付く以外は通常のEC2と同一です。
# AMI一覧の取得
C:\> aws ec2 describe-images --query 'Images[*].{ImageId:ImageId, Description:Description}' --endpoint-url http://192.168.9.150:8008 --profile snowcone
[
    {
        "ImageId": "s.ami-018b9904c8f8fc655",
        "Description": "Custom CentOS 7 AMI for Snowcone"
    },
    {
        "ImageId": "s.ami-0482ebcc91d53dd90",
        "Description": "My custom snowcone AMI"
    },
    {
        "ImageId": "s.ami-0594e7c840805e5b7",
        "Description": "AWS DataSync Agent AMI for online data transfer"
    },
    {
        "ImageId": "s.ami-0ce71111a20124b14",
        "Description": "Custom Ubuntu 16 AMI for Snowcone"
    },
    {
        "ImageId": "s.ami-0e96d810764e93bd4",
        "Description": "Amazon Linux 2 AMI 2.0.20210219.0 x86_64 HVM gp2 for Snow Family"
    }
]
2-3. セキュリティグループの取得
aws ec2 describe-security-groupsコマンドでセキュリティグループを取得します。
Snowconeデバイスにはdefaultセキュリティグループしか存在せず、また、通常のEC2のそれとは異なりインバウンド通信も全て許可する設定となっています。
(事実上セキュリティグループが無いのと同義)
# セキュリティグループを取得
C:\> aws ec2 describe-security-groups --endpoint-url http://192.168.9.150:8008 --profile snowcone
{
    "SecurityGroups": [
        {
            "Description": "default security group",
            "GroupName": "default",
            "IpPermissions": [
                {
                    "IpProtocol": "-1",
                    "IpRanges": [
                        {
                            "CidrIp": "0.0.0.0/0"
                        }
                    ]
                }
            ],
            "GroupId": "s.sg-88cabc27426d3c6e7",
            "IpPermissionsEgress": [
                {
                    "IpProtocol": "-1",
                    "IpRanges": [
                        {
                            "CidrIp": "0.0.0.0/0"
                        }
                    ]
                }
            ]
        }
    ]
}
2-4. EC2の操作
EC2の作成はaws ec2 run-instancesコマンドで可能です。
だいたい通常のEC2の場合と同じですが、
- セキュリティグループが defaultしか存在しない
- サブネット指定は無くて良い
といった違いがあります。
なお、AWS CLIでのヒアドキュメントの使用については以下の記事を参考にしてください。
# Snowcone は default セキュリティグループのみ存在
$defaultSGID = aws ec2 describe-security-groups --query 'SecurityGroups[?GroupName==`default`].GroupId' --output text `
    --endpoint-url http://192.168.9.150:8008 --profile snowcone
# EC2の作成 : 細かい設定は環境に応じて変える
$params = @"
{
    "KeyName": "snowcone-ec2-key",
    "ImageId": "s.ami-0e96d810764e93bd4",
    "InstanceType": "snc1.micro",
    "SecurityGroupIds": ["$defaultSGID"],
    "EbsOptimized": false,
    "BlockDeviceMappings": [
        {
            "DeviceName": "/dev/xvda",
            "Ebs": {
                "DeleteOnTermination": true,
                "VolumeSize": 8,
                "VolumeType": "sbg1"
            }
        }
    ],
    "TagSpecifications": [
        {
            "ResourceType": "instance",
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "ec2-aws-cli"
                }
            ]
        }
    ]
}
"@ -replace '"', '\"'
C:\> aws ec2 run-instances --cli-input-json "$params" --endpoint-url http://192.168.9.150:8008 --profile snowcone
{
    "Instances": [
        {
            "AmiLaunchIndex": 0,
            "ImageId": "s.ami-0e96d810764e93bd4",
            "InstanceId": "s.i-87c6c111d226e1e96",
            "InstanceType": "snc1.micro",
            "KeyName": "snowcone-ec2-key",
            "State": {
                "Code": 0,
                "Name": "pending"
            },
            "EbsOptimized": false,
            "EnaSupport": false,
            "RootDeviceName": "/dev/xvda",
            "SecurityGroups": [
                {
                    "GroupName": "default",
                    "GroupId": "s.sg-88cabc27426d3c6e7"
                }
            ],
            "SourceDestCheck": false,
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "ec2-aws-cli"
                }
            ],
            "CpuOptions": {
                "CoreCount": 1,
                "ThreadsPerCore": 1
            }
        }
    ],
    "ReservationId": "s.r-86bede099513266d5"
}
インスタンス起動後にaws ec2 associate-addressコマンドでVNIをアタッチしてやります。
なお、ENIではないのでdescribe-network-interface系のコマンドは使えません。
# IPアドレスの割り当て : VNIのアドレスが --public-ip になる
C:\> aws ec2 associate-address --instance-id s.i-87c6c111d226e1e96 --public-ip 192.168.9.164 --endpoint-url http://192.168.9.150:8008 --profile snowcone
作成結果はこんな感じです。


不要になったインスタンスを削除するにはaws ec2 terminate-instancesコマンドを使います。
# インスタンスの削除
C:\> aws ec2 terminate-instances --instance-ids s.i-87c6c111d226e1e96 --endpoint-url http://192.168.9.150:8008 --profile snowcone
{
    "TerminatingInstances": [
        {
            "CurrentState": {
                "Code": 32,
                "Name": "shutting-down"
            },
            "InstanceId": "s.i-87c6c111d226e1e96",
            "PreviousState": {
                "Code": 16,
                "Name": "running"
            }
        }
    ]
}

簡単ですが以上で完了です。
参考ドキュメント
各種コマンドの詳細については以下のドキュメントをご覧ください。
【追記】AWS Tools for PowerShellでのEC2操作
せっかくなのでAWS Tools for PowerShellを使ったEC2の操作手順を追記します。
AWS Tools for PowerShellにも-EndpointUrlパラメーターは存在しますのでデバイスのエンドポイントを指定してやる点以外は通常のEC2と同様に操作できます。
現時点で最新のVer.4.1.16.0のAWS.Tools.EC2モジュールで動作確認しています。
# デフォルトプロファイル指定
C:\> Set-AWSCredential -ProfileName snowcone
C:\> Set-DefaultAWSRegion -Region ap-northeast-1
# AMIの取得
C:\> Get-EC2Image -Select Images -EndpointUrl http://192.168.9.150:8008 | Select-Object ImageId, Description
ImageId                 Description
-------                 -----------
s.ami-018b9904c8f8fc655 Custom CentOS 7 AMI for Snowcone
s.ami-0482ebcc91d53dd90 My custom snowcone AMI
s.ami-0594e7c840805e5b7 AWS DataSync Agent AMI for online data transfer
s.ami-0ce71111a20124b14 Custom Ubuntu 16 AMI for Snowcone
s.ami-0e96d810764e93bd4 Amazon Linux 2 AMI 2.0.20210219.0 x86_64 HVM gp2 for Snow Family
# セキュリティグループの取得
C:\> Get-EC2SecurityGroup -EndpointUrl http://192.168.9.150:8008 | Where-Object { $_.GroupName -eq 'default' }
Description         : default security group
GroupId             : s.sg-88cabc27426d3c6e7
GroupName           : default
IpPermissions       : {Amazon.EC2.Model.IpPermission}
IpPermissionsEgress : {Amazon.EC2.Model.IpPermission}
OwnerId             :
Tags                : {}
VpcId               :
# EC2の作成
C:\> $params = @{
    KeyName = 'snowcone-ec2-key'
    ImageId = 's.ami-0e96d810764e93bd4'
    InstanceType = 'snc1.micro'
    SecurityGroupId = (Get-EC2SecurityGroup -EndpointUrl http://192.168.9.150:8008 | Where-Object { $_.GroupName -eq 'default' }).GroupId
    EbsOptimized = $false
    BlockDeviceMapping = @(
        # EBS1
        [Amazon.EC2.Model.BlockDeviceMapping]@{
            DeviceName = '/dev/xvda'
            Ebs = @{
                VolumeType = 'sbg1'
                VolumeSize = 8
                DeleteOnTermination = $true
            }
        }
    )
    TagSpecification = @{
        ResourceType = 'Instance';
        Tags         = @( @{Key = 'Name'; value = 'ec2-aws-tools-for-pwsh'});
    }
}
C:\> New-EC2Instance @params -EndpointUrl http://192.168.9.150:8008
GroupNames    : {}
Groups        : {}
Instances     : {snowcone-ec2-key}
OwnerId       :
RequesterId   :
ReservationId : s.r-83a37b53add892c6c
# IPアドレスの割り当て
C:\> Register-EC2Address -InstanceId s.i-8c553274adda9c217 -PublicIp 192.168.9.164 -EndpointUrl http://192.168.9.150:8008
# 結果確認
C:\> Get-EC2Instance -Select Reservations.Instances -EndpointUrl http://192.168.9.150:8008
InstanceId            InstanceType Platform PrivateIpAddress PublicIpAddress SecurityGroups SubnetId VpcId
----------            ------------ -------- ---------------- --------------- -------------- -------- -----
s.i-8c553274adda9c217 snc1.micro            34.223.14.193    192.168.9.164   {default}
# インスタンスの削除
C:\> Remove-EC2Instance -InstanceId s.i-8c553274adda9c217 -Force -EndpointUrl http://192.168.9.150:8008
CurrentState                   InstanceId            PreviousState
------------                   ----------            -------------
Amazon.EC2.Model.InstanceState s.i-8c553274adda9c217 Amazon.EC2.Model.InstanceState
終わりに
今回はここまでです。
次はデバイス返却からその後の処理について解説する予定です。
- まあ、IP指定ですし... ↩︎ 












