Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan PutInventory
dengan AWS SDK atau CLI
Contoh kode berikut menunjukkan cara menggunakanPutInventory
.
- CLI
-
- AWS CLI
-
Untuk menetapkan metadata pelanggan ke sebuah instance
Contoh ini menetapkan informasi lokasi rak ke instans. Tidak ada output jika perintah berhasil.
Perintah (Linux):
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"}]}]
'Perintah (Windows):
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'}]"
-
Untuk API detailnya, lihat PutInventory
di Referensi AWS CLI Perintah.
-
- PowerShell
-
- Alat untuk PowerShell
-
Contoh 1: Contoh ini memberikan informasi lokasi rak ke sebuah instance. Tidak ada output jika perintah berhasil.
$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
-
Untuk API detailnya, lihat PutInventorydi AWS Tools for PowerShell Referensi Cmdlet.
-