All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ESS-LifeCycleApplyAutoSnapshotPolicy

Last Updated:Dec 24, 2024

Template name

ACS-ESS-LifeCycleApplyAutoSnapshotPolicy

Execute Now

Template description

Uses a lifecycle hook to apply an automatic snapshot policy in disks. This action is supported only during a scaling activity.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Data type

Required

Default value

Limit

autoSnapshotPolicyId

The ID of the automatic snapshot policy.

String

Yes

regionId

The region ID.

String

No

${regionId}

instanceIds

The list of ECS instance IDs.

List

No

['${instanceIds}']

lifecycleHookId

The lifecycle hook ID.

String

No

${lifecycleHookId}

lifecycleActionToken

The token of a specific scaling activity that is associated with the instances.

String

No

${lifecycleActionToken}

OOSAssumeRole

The RAM role that is assumed by CloudOps Orchestration Service (OOS).

String

No

OOSServiceRole

Output parameters

N/A.

Permission policy that is required to execute the template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:ApplyAutoSnapshotPolicy",
                "ecs:DescribeDisks",
                "ecs:DescribeInstances"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ess:CompleteLifecycleAction"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

References

ACS-ESS-LifeCycleApplyAutoSnapshotPolicy

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Use lifecycleHook to apply an automatic snapshot policy to one or more disks, only supports elastic expansion activities  
  name-en: ACS-ESS-LifeCycleApplyAutoSnapshotPolicy  
  categories:
    - elastic_manage
Parameters:
  autoSnapshotPolicyId:
    Label:
      en: AutoSnapshotPolicyId      
    Description:
      en: The ID of the automatic snapshot policy       
    Type: String
  regionId:
    Label:
      en: RegionId       
    Description:
      en: The ID of region      
    Type: String
    Default: '${regionId}'
  instanceIds:
    Label:
      en: InstanceIds       
    Description:
      en: The ID list of the ECS instance       
    Type: List
    Default:
      - '${instanceIds}'
  lifecycleHookId:
    Label:
      en: LifecycleHookId       
    Description:
      en: The ID of the lifecycle hook       
    Type: String
    Default: '${lifecycleHookId}'
  lifecycleActionToken:
    Label:
      en: LifecycleActionToken       
    Description:
      en: The token that indicates a specific scaling activity associated with an instance      
    Type: String
    Default: '${lifecycleActionToken}'
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole       
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: untilInstanceReady
    Action: 'ACS::WaitFor'
    Description: Waits for the created instances to be Running
    OnError: CompleteLifecycleActionForAbandon
    Properties:
      Service: ECS
      API: DescribeInstances
      Parameters:
        RegionId: '{{ regionId }}'
        InstanceIds:
          - '{{ ACS::TaskLoopItem }}'
      DesiredValues:
        - Running
      PropertySelector: 'Instances.Instance[].Status'
    Loop:
      Concurrency: 1
      Items: '{{ instanceIds }}'
  - Name: applyAutoSnapshotPolicy
    Action: ACS::ECS::ApplyAutoSnapshotPolicy
    Description: Apply AutoSnapshot policy.
    OnError: CompleteLifecycleActionForAbandon
    OnSuccess: CompleteLifecycleActionForContinue
    Properties:
      regionId: '{{ regionId }}'
      autoSnapshotPolicyId: '{{ autoSnapshotPolicyId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
    Loop:
      Concurrency: 1
      Items: '{{ instanceIds }}'
  - Name: CompleteLifecycleActionForContinue
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Modify lifecycle action for continue       
    OnSuccess: 'ACS::END'
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: CONTINUE
  - Name: CompleteLifecycleActionForAbandon
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Complete lifecycle action for Abandon      
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: ABANDON