AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
搭PutInventory
配 AWS SDK或使用 CLI
下列程式碼範例會示範如何使用PutInventory
。
- CLI
-
- AWS CLI
-
若要指派客戶中繼資料給執行個體
此範例會將機架位置資訊指派給執行個體。如果命令成功,則無輸出訊息。
命令:
aws ssm put-inventory --instance-id
"i-016648b75dd622dab"
--items '[{"TypeName": "Custom:RackInfo","SchemaVersion": "1.0","CaptureTime": "2019-01-22T10:01:01Z","Content":[{"RackLocation": "Bay B/Row C/Rack D/Shelf E"}]}]
'指令 (視窗):
aws ssm put-inventory --instance-id
"i-016648b75dd622dab"
--items"TypeName=Custom:RackInfo,SchemaVersion=1.0,CaptureTime=2019-01-22T10:01:01Z,Content=[{RackLocation='Bay B/Row C/Rack D/Shelf F'}]"
-
如需詳API細資訊,請參閱AWS CLI 指令參考PutInventory
中的。
-
- PowerShell
-
- 適用的工具 PowerShell
-
範例 1:此範例將機架位置資訊指定給執行個體。如果命令成功,則沒有輸出。
$data = New-Object "System.Collections.Generic.Dictionary[System.String,System.String]" $data.Add("RackLocation", "Bay B/Row C/Rack D/Shelf F") $items = New-Object "System.Collections.Generic.List[System.Collections.Generic.Dictionary[System.String, System.String]]" $items.Add($data) $customInventoryItem = New-Object Amazon.SimpleSystemsManagement.Model.InventoryItem $customInventoryItem.CaptureTime = "2016-08-22T10:01:01Z" $customInventoryItem.Content = $items $customInventoryItem.TypeName = "Custom:TestRackInfo2" $customInventoryItem.SchemaVersion = "1.0" $inventoryItems = @($customInventoryItem) Write-SSMInventory -InstanceId "i-0cb2b964d3e14fd9f" -Item $inventoryItems
-
如需詳API細資訊,請參閱AWS Tools for PowerShell 指令程PutInventory式參考中的。
-
PutComplianceItems
PutParameter