Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan CreateSnapshot
dengan CLI
Contoh kode berikut menunjukkan cara menggunakanCreateSnapshot
.
- CLI
-
- AWS CLI
-
Untuk membuat snapshot
Perintah contoh ini membuat snapshot volume dengan ID volume
vol-1234567890abcdef0
dan deskripsi singkat untuk mengidentifikasi snapshot.Perintah:
aws ec2 create-snapshot --volume-id
vol-1234567890abcdef0
--description"This is my root volume snapshot"
Output:
{ "Description": "This is my root volume snapshot", "Tags": [], "Encrypted": false, "VolumeId": "vol-1234567890abcdef0", "State": "pending", "VolumeSize": 8, "StartTime": "2018-02-28T21:06:01.000Z", "Progress": "", "OwnerId": "012345678910", "SnapshotId": "snap-066877671789bd71b" }
Untuk membuat snapshot dengan tag
Perintah contoh ini membuat snapshot dan menerapkan dua tag: purpose=prod dan costcenter=123.
Perintah:
aws ec2 create-snapshot --volume-id
vol-1234567890abcdef0
--description 'Prod backup
' --tag-specifications 'ResourceType=snapshot,Tags=[{Key=purpose,Value=prod},{Key=costcenter,Value=123}]
'Output:
{ "Description": "Prod backup", "Tags": [ { "Value": "prod", "Key": "purpose" }, { "Value": "123", "Key": "costcenter" } ], "Encrypted": false, "VolumeId": "vol-1234567890abcdef0", "State": "pending", "VolumeSize": 8, "StartTime": "2018-02-28T21:06:06.000Z", "Progress": "", "OwnerId": "012345678910", "SnapshotId": "snap-09ed24a70bc19bbe4" }
-
Untuk detail API, lihat CreateSnapshot
di Referensi AWS CLI Perintah.
-
- PowerShell
-
- Alat untuk PowerShell
-
Contoh 1: Contoh ini membuat snapshot dari volume yang ditentukan.
New-EC2Snapshot -VolumeId vol-12345678 -Description "This is a test"
Output:
DataEncryptionKeyId : Description : This is a test Encrypted : False KmsKeyId : OwnerAlias : OwnerId : 123456789012 Progress : SnapshotId : snap-12345678 StartTime : 12/22/2015 1:28:42 AM State : pending StateMessage : Tags : {} VolumeId : vol-12345678 VolumeSize : 20
-
Untuk detail API, lihat CreateSnapshotdi Referensi Alat AWS untuk PowerShell Cmdlet.
-