Edited at

WorkSpaces の資産管理をコマンドでレポート

※自分メモ

4台のWSがいる状態

$ aws workspaces describe-workspaces --query 'Workspaces[*].{Directory:DirectoryId,User:UserName,WS:WorkspaceId,Bundle:BundleId,State:State,RunMode:WorkspaceProperties.RunningMode,TimeOut:WorkspaceProperties.RunningMode,Timeout:Workspaces.RunningModeAutoStopTimeoutInMinutes}'  

[
{
"Timeout": null,
"Bundle": "wsb-xxxxxxxx1",
"RunMode": "AUTO_STOP",
"State": "STOPPED",
"WS": "ws-yyyyyyyy1",
"User": "uehara",
"TimeOut": "AUTO_STOP",
"Directory": "d-zzzzzzzzz1"
},
{
"Timeout": null,
"Bundle": "wsb-xxxxxxxx2",
"RunMode": "AUTO_STOP",
"State": "AVAILABLE",
"WS": "ws-yyyyyyyy2",
"User": "takahashi",
"TimeOut": "AUTO_STOP",
"Directory": "d-zzzzzzzzz1"
},
{
"Timeout": null,
"Bundle": "wsb-xxxxxxxx3",
"RunMode": "AUTO_STOP",
"State": "AVAILABLE",
"WS": "ws-yyyyyyyy3",
"User": "sato",
"TimeOut": "AUTO_STOP",
"Directory": "d-zzzzzzzzz1"
},
{
"Timeout": null,
"Bundle": "wsb-xxxxxxxx4",
"RunMode": "AUTO_STOP",
"State": "STOPPED",
"WS": "ws-yyyyyyyy4",
"User": "uehara1",
"TimeOut": "AUTO_STOP",
"Directory": "d-zzzzzzzzz1"
}
]

ユーザー名からWorkspaces ID検索

$ aws workspaces describe-workspaces --query 'Workspaces[*].{User:UserName,WS:WorkspaceId}'  --output text | grep takahashi

takahashi ws-yyyyyyyy1

起動中台数確認

$ aws workspaces describe-workspaces --query 'Workspaces[*].{State:State}'  | grep '"State": "AVAILABLE"' | wc -l 

2

停止中台数確認

$ aws workspaces describe-workspaces --query 'Workspaces[*].{State:State}'  | grep '"State": "STOPPED"' | wc -l 

2

停止中のノードリスト

$ aws workspaces describe-workspaces --query 'Workspaces[*].{Directory:DirectoryId,User:UserName,WS:WorkspaceId,Bundle:BundleId,State:State,RunMode:WorkspaceProperties.RunningMode,TimeOut:WorkspaceProperties.RunningMode,Timeout:Workspaces.RunningModeAutoStopTimeoutInMinutes}' --output table | head -5 ;aws workspaces describe-workspaces --query 'Workspaces[*].{Directory:DirectoryId,User:UserName,WS:WorkspaceId,Bundle:BundleId,State:State,RunMode:WorkspaceProperties.RunningMode,TimeOut:WorkspaceProperties.RunningMode,Timeout:Workspaces.RunningModeAutoStopTimeoutInMinutes}'  --output table | grep STOPPED

------------------------------------------------------------------------------------------------------------------
| DescribeWorkspaces |
+---------------+---------------+------------+------------+------------+----------+-------------+----------------+
| Bundle | Directory | RunMode | State | TimeOut | Timeout | User | WS |
+---------------+---------------+------------+------------+------------+----------+-------------+----------------+
| wsb-xxxxxxxx1| d-zzzzzzzzz1 | AUTO_STOP | STOPPED | AUTO_STOP | None | uehara | ws-yyyyyyyy1 |
| wsb-xxxxxxxx4| d-zzzzzzzzz1 | AUTO_STOP | STOPPED | AUTO_STOP | None | uehara1 | ws-yyyyyyyy4 |

実行モードごとの台数確認(AlwaysOnかAutoStop)

以下はAutoStopの実行モードのノード数

$ aws workspaces describe-workspaces --query 'Workspaces[*].{Directory:DirectoryId,User:UserName,WS:WorkspaceId,Bundle:BundleId,State:State,RunMode:WorkspaceProperties.RunningMode,TimeOut:WorkspaceProperties.RunningMode,Timeout:Workspaces.RunningModeAutoStopTimeoutInMinutes}'  --output table | grep AUTO_STOP | wc -l

4

ディレクトリ(AD)のリスト

$ aws workspaces describe-workspaces --query 'Workspaces[*].{Directory:DirectoryId,User:UserName,WS:WorkspaceId,Bundle:BundleId,State:State,RunMode:WorkspaceProperties.RunningMode,TimeOut:WorkspaceProperties.RunningMode,Timeout:Workspaces.RunningModeAutoStopTimeoutInMinutes}'  | grep Directory | uniq

"Directory": "d-zzzzzzzzz1"

バンドルのリスト

$ aws workspaces describe-workspaces --query 'Workspaces[*].{Directory:DirectoryId,User:UserName,WS:WorkspaceId,Bundle:BundleId,State:State,RunMode:WorkspaceProperties.RunningMode,TimeOut:WorkspaceProperties.RunningMode,Timeout:Workspaces.RunningModeAutoStopTimeoutInMinutes}'  | grep Bundle | uniq

"Bundle": "wsb-xxxxxxxx1",
"Bundle": "wsb-xxxxxxxx2",
"Bundle": "wsb-xxxxxxxx3",
"Bundle": "wsb-xxxxxxxx4",


QuickSight

台数おおければグラフィカルなレポート

スクリーンショット 0030-09-07 11.35.06.png