All Products
Search
Document Center

Elastic Compute Service:CreateAutoSnapshotPolicy

Last Updated:Oct 22, 2026

Creates an automatic snapshot policy in a specified region. You can specify the repetition cycle, retention period, and cross-region backup settings to create snapshot backups for system cloud disks or data cloud disks.

Operation description

Before calling this operation, read Create an automatic snapshot policy carefully.

When you call this operation, take note of the following items:

  • An Alibaba Cloud account can create up to 100 automatic snapshot policies in a region. If the number of automatic snapshots for a cloud disk reaches the quota limit, the system deletes the earliest automatic snapshot generated by the automatic snapshot policy when creating a new snapshot task.

  • The system does not execute the automatic snapshot policy when an ECS instance has a stop or restart task.

  • If cross-region snapshot replication is enabled and no encryption parameters are configured, encrypted snapshots are encrypted and copied by using the destination service key by default. For precautions about cross-region snapshot replication, refer to Copy a snapshot.

After creating an automatic snapshot policy, you must call ApplyAutoSnapshotPolicy to apply the policy to the target cloud disks. To modify the automatic snapshot policy, call ModifyAutoSnapshotPolicyEx.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:CreateAutoSnapshotPolicy

create

*AutoSnapshotPolicy

acs:ecs:{#regionId}:{#accountId}:snapshotpolicy/*

None None

Request parameters

Parameter

Type

Required

Description

Example

regionId

string

Yes

The region to which the automatic snapshot policy belongs. You can call DescribeRegions to query the most recent region list.

cn-hangzhou

autoSnapshotPolicyName

string

No

The name of the automatic snapshot policy. The name must be 2 to 128 characters in length and must start with a letter or a Chinese character. It cannot start with http:// or https://. It can contain digits, colons (:), underscores (_), and hyphens (-).

Default value: null.

TestName

timePoints

string

Yes

The points in time at which automatic snapshots are created. The time is in UTC+8 and measured in hours. Valid values: 0 to 23, which represent 24 points in time from 00:00 to 23:00. For example, 1 indicates 01:00. Format description:

  • The parameter must be in JSON array format. For example, ["1"] indicates that automatic snapshots are created at 01:00.

  • If you want to create multiple automatic snapshots in a day, you can specify multiple points in time separated by commas (,). You can specify up to 24 points in time. For example, ["1","3","5"] indicates that automatic snapshots are created at 01:00, 03:00, and 05:00.

Note

If the cloud disk contains a large amount of data and the time taken to create a single automatic snapshot exceeds the interval between two points in time, the system skips the next point in time. For example, if you set 09:00, 10:00, 11:00, and 12:00 as the points in time for automatic snapshots, and the snapshot creation starts at 09:00 and finishes at 10:20, taking 80 minutes, the system skips 10:00 and creates the next automatic snapshot at 11:00.

["0", "1", … "23"]

repeatWeekdays

string

Yes

The days of the week on which automatic snapshots are created. The unit is days and the cycle is weeks. Valid values: 1 to 7. For example, 1 indicates Monday. Format description:

  • The parameter must be in JSON array format. For example, ["1"] indicates that automatic snapshots are created every Monday.

  • If you want to create automatic snapshots multiple times a week, you can specify multiple days separated by commas (,). You can specify up to 7 days. For example, ["1","3","5"] indicates that automatic snapshots are created every Monday, Wednesday, and Friday.

["1","2"]

retentionDays

integer

Yes

The retention period of automatic snapshots. Unit: days. Valid values:

  • -1: The snapshots are permanently retained.

  • 1 to 65535: The specified number of days for which the snapshots are retained.

Default value: -1.

30

EnableCrossRegionCopy

boolean

No

Specifies whether to enable automatic cross-region replication. Valid values:

  • true: Enabled.

  • false: Disabled.

false

TargetCopyRegions

string

No

The destination region for cross-region snapshot replication. You can specify only one destination region.

["cn-hangzhou"]

StorageLocationArn

string

No

Note

This parameter is not available.

null

CopiedSnapshotsRetentionDays

integer

No

The retention period of cross-region replicated snapshots. Unit: days. Valid values:

  • -1: The snapshots are permanently retained.

  • 1 to 65535: The specified number of days for which the snapshots are retained.

Default value: -1.

30

CopyEncryptionConfiguration

object

No

The backup encryption parameters for snapshot geo-redundancy.

Arn

array<object>

No

Note

This parameter is not available.

object

No

AssumeRoleFor

integer

No

Note

This parameter is not available.

1000000000

RoleType

string

No

Note

This parameter is not available.

hide

Rolearn

string

No

Note

This parameter is not available.

hide

Encrypted

boolean

No

Specifies whether to enable encryption for cross-region snapshot backups. Valid values:

  • true: Yes.

  • false: No.

Default value: false.

false

KMSKeyId

string

No

The KMS key ID used for snapshot geo-redundancy backup encryption.

0e478b7a-4262-4802-b8cb-00d3fb40826X

ResourceGroupId

string

No

The ID of the resource group.

rg-aek2kkmhmhs****

Tag

array<object>

No

The list of tags for the automatic snapshot policy.

object

No

Key

string

No

The tag key of the automatic snapshot policy. Valid values of N: 1 to 20. If you specify this parameter, it cannot be an empty string. The tag key can be up to 128 characters in length. It cannot start with aliyun or acs: and cannot contain http:// or https://.

TestKey

Value

string

No

The tag value of the automatic snapshot policy. Valid values of N: 1 to 20. If you specify this parameter, it can be an empty string. The tag value can be up to 128 characters in length. It cannot start with acs: and cannot contain http:// or https://.

TestValue

AssociationType

string

No

The association type between the automatic snapshot policy and target resources. Valid values:

  • AssociatedWithDisk: Associated with cloud disks.

  • AssociatedWithInstanceTag: Associated with instance tags.

Default value: AssociatedWithDisk.

AssociatedWithDisk

TargetTags

array<object>

No

The list of target resource tags. The automatic snapshot policy matches target resources based on tags. This parameter is required when AssociationType is set to AssociatedWithInstanceTag.

object

No

The target resource tag.

Key

string

No

The tag key.

Valid values of N: 1 to 5.

If you specify this parameter, it cannot be an empty string. The tag key can be up to 128 characters in length. It cannot start with aliyun or acs: and cannot contain http:// or https://.

TestKey

Value

string

No

The tag value.

Valid values of N: 1 to 5.

The tag value can be up to 128 characters in length and cannot contain http:// or https://.

Note

If you leave this parameter empty or specify an empty string, it indicates any value.

TestValue

Response elements

Element

Type

Description

Example

object

AutoSnapshotPolicyId

string

The ID of the automatic snapshot policy.

sp-bp12m37ccmxvbmi5****

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Success response

JSON format

{
  "AutoSnapshotPolicyId": "sp-bp12m37ccmxvbmi5****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Error codes

HTTP status code

Error code

Error message

Description

400 DiskCategory.OperationNotSupported The type of the specified disk does not support creating a snapshot. The operation is not supported by the current disk category.
400 InvalidSnapshotPolicyName.Malformed The specified autoSnapshotPolicyName is malformed.
400 Duplicate.TagKey The parameter Tag.N.Key contains duplicate values. Please remove the duplicate tag keys and try again.
400 InvalidTagKey.Malformed The specified Tag.n.Key is not valid. The specified Tag.N.Key parameter is invalid.
400 InvalidTagValue.Malformed The specified Tag.n.Value is not valid. The specified tag value is invalid.
400 InvalidParameter.EncryptedIllegal The Encrypted parameter must be set to true when KMSKeyId is specified. Please adjust the parameters and try again.
400 InvalidParameter.KmsNotEnabled The operation failed because KMS is not activated. Please activate KMS in the KMS console and try again.
400 InvalidParameter.Encrypted.KmsNotEnable The operation failed because KMS is not activated. Please activate KMS in the KMS console and try again.
400 InvalidParam.EncryptedMismatch Creating a disk from a shared encrypted image requires encryption with your own KMS key. Please set the Encrypted parameter to true.
400 InvalidAssociationType.Malformed The specified parameter AssociationType is invalid. Please check the valid range for this parameter.
400 MissingParameter.TargetTags When the parameter AssociationType is set to AssociatedWithInstanceTag, the TargetTags parameter is required.
400 InvalidTargetTags.NotSupported The TargetTags parameter is not supported when AssociationType is set to AssociatedWithDisk. Please remove TargetTags and try again.
400 InvalidTargetTagKey.Malformed The specified TargetTag.n.Key [%s] is not valid.
400 InvalidTargetTagValue.Malformed The specified TargetTag.n.Value [%s] is not valid.
400 Duplicate.TargetTagKey Duplicate keys exist in the specified parameter TargetTags. Please ensure key uniqueness.
400 InvalidTargetTag.LimitExceed The number [%s] of the specified parameter TargetTag exceeds the limit [%s].
403 ParameterInvalid The specified RegionId parameter is invalid. The specified region ID is invalid.
403 AutoSnapshotPolicy.QuotaExceed The maximum number of automatic snapshot policy has been reached.
403 InvalidAccountStatus.NotEnoughBalance Your account does not have enough balance.
403 InvalidAccountStatus.SnapshotServiceUnavailable The snapshot service has not been activated. Please activate it and try again.
403 InvalidParameter.TargetCopyRegions The specified TargetCopyRegions is invalid.
403 InvalidParameter.CopiedSnapshotsRetentionDays The specified CopiedSnapshotsRetentionDays is invalid.
403 InvalidParameter.KMSKeyId.KMSUnauthorized ECS service does not have permission to access your KMS key. Please verify that the specified KMS key has authorized the ECS service.
403 InvalidOperation.KMSKeyIdNotFound The specified KMSKeyId does not exist. Please verify that the key ID is correct and that the key resides in the current region.
403 Abs.InvalidAction.RegionNotSupport The current operation is not supported in the specified region. Please switch to a supported region and try again.
403 InvalidParameter.KMSKeyId.CMKNotEnabled The specified KMS key must be in an enabled state. Please enable the key in the KMS console and try again.
403 InvalidParameter.KMSKeyId.CMKUnauthorized The specified KMS key is not authorized for the ECS service. Please grant the ECS service permission to use the key in the KMS console and try again.
403 InvalidStorageLocationArn.Malformed The specified parameter StorageLocationArn is malformed.
403 InvalidOperation.UserNotInWhiteList The current user is temporarily unable to use this feature. Please submit a ticket for assistance.
403 InvalidOperation.CopyingDataToThisRegionUnsupported Data transfer to the current region from other regions is not supported. Data transfer to the current region from other regions is not supported.
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. The specified resource group does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.