LockSnapshot
Locks a snapshot in compliance mode to prevent accidental or malicious deletion. During the lock period, no user can delete the snapshot.
Operation description
You can also use this operation to reconfigure a locked snapshot. The configurable items depend on the lock mode and lock status:
If the snapshot is locked in compliance mode and is in the cool-off period, you can extend or shorten the cool-off period, or extend or shorten the lock duration.
If the snapshot is locked in compliance mode and the cool-off period has expired, you can only extend the lock duration.
If you reconfigure a locked snapshot during the cool-off period, the system treats it as a re-lock operation. All lock parameters are reset instead of being adjusted individually.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:LockSnapshot |
update |
*Snapshot
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID. You can call the DescribeRegions operation to query the most recent region list. |
cn-hangzhou |
| SnapshotId |
string |
Yes |
The snapshot ID. |
s-9dp2qojdpdfmgfmf**** |
| LockMode |
string |
Yes |
The lock mode. Valid values:
|
compliance |
| LockDuration |
integer |
Yes |
The lock duration. The snapshot lock automatically expires after the lock duration ends. Unit: days. Valid values: 1 to 36500. |
1 |
| CoolOffPeriod |
integer |
Yes |
The cool-off period. In compliance mode, you can set a cool-off period or skip the cool-off period to lock the snapshot directly. During the cool-off period, users with the required RAM permissions can unlock the snapshot, extend or shorten the cool-off period, and extend or shorten the lock duration. The snapshot cannot be deleted during the cool-off period. After the cool-off period ends, you can only extend the lock duration. Unit: hours. Valid values: 0 to 72. A value of 0 indicates that the cool-off period is skipped and the snapshot is locked directly. If the snapshot has entered the compliance mode lock period, you must set this parameter to 0 to extend the lock duration. |
3 |
| DryRun |
boolean |
No |
Specifies whether to perform only a dry run on the request. Valid values:
|
false |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that the value is unique among different requests. The client token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence. |
5EC38E7D-389F-1925-ABE2-D7925A8F**** |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| LockedSnapshotInfo |
object |
The locked snapshot information. |
|
| SnapshotId |
string |
The snapshot ID. |
s-9dp2qojdpdfmgfmf**** |
| LockMode |
string |
The lock mode. Valid values:
|
compliance |
| LockStatus |
string |
The lock status. Valid values:
|
compliance-cooloff |
| LockCreationTime |
string |
The time when the snapshot was locked. The time is displayed in the yyyy-MM-ddTHH:mm:ssZ format based on the ISO 8601 standard. UTC+0 is used. |
2025-10-15T10:00:00Z |
| CoolOffPeriod |
integer |
The cool-off period in compliance mode. Unit: hours. |
3 |
| CoolOffPeriodExpiredTime |
string |
The end time of the cool-off period in compliance mode. The time is displayed in the yyyy-MM-ddTHH:mm:ssZ format based on the ISO 8601 standard. UTC+0 is used. |
2025-10-15T13:00:00Z |
| LockDuration |
integer |
The lock duration. The snapshot lock automatically expires after the lock duration ends. Unit: days. |
1 |
| LockDurationStartTime |
string |
The start time of the lock duration. The time is displayed in the yyyy-MM-ddTHH:mm:ssZ format based on the ISO 8601 standard. UTC+0 is used. If you lock a snapshot that is in the progressing state, the lock duration is calculated only after the snapshot enters the accomplished state. |
2025-10-15T10:00:00Z |
| LockExpiredTime |
string |
The expiration time of the lock. The time is displayed in the yyyy-MM-ddTHH:mm:ssZ format based on the ISO 8601 standard. UTC+0 is used. |
2025-10-16T10:00:00Z |
Examples
Success response
JSON format
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"LockedSnapshotInfo": {
"SnapshotId": "s-9dp2qojdpdfmgfmf****",
"LockMode": "compliance",
"LockStatus": "compliance-cooloff",
"LockCreationTime": "2025-10-15T10:00:00Z",
"CoolOffPeriod": 3,
"CoolOffPeriodExpiredTime": "2025-10-15T13:00:00Z",
"LockDuration": 1,
"LockDurationStartTime": "2025-10-15T10:00:00Z",
"LockExpiredTime": "2025-10-16T10:00:00Z"
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidLockMode.Malformed | The specified parameter LockMode is invalid. Please check the valid range for this parameter. | The specified parameter LockMode is invalid. Please check the valid range for this parameter. |
| 400 | InvalidLockDuration.ExceedRetentionDays | The specified parameter LockDuration is invalid. The LockDuration should be less than the snapshot RetentionDays. | The specified parameter LockDuration is invalid. The LockDuration should be less than the snapshot RetentionDays. |
| 400 | InvalidCoolOffPeriod.ExceedLockDuration | The specified parameter CoolOffPeriod is invalid. The CoolOffPeriod should be less than the LockDuration. | The specified parameter CoolOffPeriod is invalid. The CoolOffPeriod should be less than the LockDuration. |
| 403 | InvalidOperation.SnapshotNotAvailable | The unavailable snapshot does not support locking. | The unavailable snapshot does not support locking. |
| 403 | InvalidOperation.ResourceManagedByCloudProduct | The current operation is not supported because the resource is managed by a cloud product [%s]. Please contact the relevant cloud product to confirm the reason. | The current operation is not supported because the resource is managed by a cloud product. Please contact the relevant cloud product to confirm the reason. |
| 403 | InvalidOperation.LockSharedSnapshotUnsupported | The shared snapshot does not support locking. | The shared snapshot does not support locking. |
| 403 | InvalidOperation.CoolOffPeriodExpired | The snapshot is locked in compliance mode; and the cool-off period has expired. The current operation is not supported. | |
| 404 | InvalidSnapshotId.NotFound | The specified snapshot is not found. | The specified Snapshot does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.