Template name
ACS-ESS-LifeCycleAllocateEipAddressAndAttachToInstance: Uses a lifecycle hook to create an EIP and attach it to an instance
Template description
Uses a lifecycle hook to create elastic IP addresses (EIPs) and associate the EIPs with Elastic Compute Service (ECS) instances. This template supports only scale-out events.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
internetChargeType | The billing method of the EIPs. | String | No | PayByBandwidth | |
bandwidth | The peak bandwidth of the EIPs. | Number | No | 5 | |
regionId | The region ID. | String | No | ${regionId} | |
instanceIds | The IDs of the ECS instances. | List | No | ['${instanceIds}'] | |
eipTags | The tags of the EIPs. | Json | No | [{'Key': 'oos_generate', 'Value': '{{ACS::ExecutionId}}'}] | |
ISP | The line type of the EIPs. | String | No | BGP | |
lifecycleHookId | The ID of the lifecycle hook. | String | No | ${lifecycleHookId} | |
lifecycleActionToken | Rate Control | String | No | ${lifecycleActionToken} | |
rateControl | The rate control settings. | Json | No | {'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 5} | |
OOSAssumeRole | The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS). | String | No | OOSServiceRole |
Output parameters
None
Policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:AllocateEipAddress",
"ecs:AssociateEipAddress",
"ecs:DescribeEipAddresses",
"ecs:DescribeInstances",
"ecs:ReleaseEipAddress",
"ecs:UnassociateEipAddress"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"vpc:TagResources"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ess:CompleteLifecycleAction"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
ACS-ESS-LifeCycleAllocateEipAddressAndAttachToInstance
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Uses a lifecycle hook to create EIPs and attach them to instances. This template supports only scale-out activities.
name-en: ACS-ESS-LifeCycleAllocateEipAddressAndAttachToInstance
categories:
- elastic_manage
Parameters:
internetChargeType:
Label:
en: Billing Method for EIP
Description:
en: 'The billing method for the EIP. Valid values: PayByBandwidth (pay-by-bandwidth) and PayByTraffic (pay-by-data-transfer).'
Type: String
AllowedValues:
- PayByBandwidth
- PayByTraffic
Default: PayByBandwidth
bandwidth:
Label:
en: EIP Peak Bandwidth
Description:
en: The peak bandwidth of the EIP, in Mbit/s.
Type: Number
Default: 5
regionId:
Label:
en: Region ID
Description:
en: The ID of the region. Use the default value ${regionId} provided by Auto Scaling.
Type: String
Default: '${regionId}'
instanceIds:
Label:
en: ECS Instance IDs
Description:
en: The IDs of the ECS instances. Use the default value ['${instanceIds}'] provided by Auto Scaling.
Type: List
Default:
- '${instanceIds}'
eipTags:
Label:
en: EIP Tags
Description:
en: 'The tags for the EIP. Format: [{"Key":"test1","Value":"test1"},{"Key":"test2","Value":"test2"}, ...].'
Type: Json
Default: [{"Key":"oos_generate","Value":"{{ACS::ExecutionId}}"}]
ISP:
Label: EIP Line Type
Description: 'The line type of the EIP. BGP: BGP (Multi-ISP). BGP_PRO: BGP (Multi-ISP) Pro. BGP_International: BGP (International).'
Type: String
AllowedValues:
- BGP
- BGP_PRO
- BGP_International
Default: BGP
lifecycleHookId:
Label:
en: Lifecycle Hook ID
Description:
en: The ID of the lifecycle hook. Use the default value ${lifecycleHookId} provided by Auto Scaling.
Type: String
Default: '${lifecycleHookId}'
lifecycleActionToken:
Label:
en: Lifecycle Action Token
Description:
en: The token for the specific scaling activity that is associated with the instance. Use the default value ${lifecycleActionToken} provided by Auto Scaling.
Type: String
Default: '${lifecycleActionToken}'
rateControl:
Label:
en: Rate Control
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 5
OOSAssumeRole:
Label:
en: RAM Role for OOS
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: createEipAndAttachToInstance
Action: 'ACS::ECS::AllocateEipAddressAndAttachToInstance'
OnSuccess: CompleteLifecycleActionForContinue
OnError: CompleteLifecycleActionForAbandon
Description:
en: Creates an EIP and attaches it to the instance.
Properties:
regionId: '{{ regionId }}'
internetChargeType: '{{ internetChargeType }}'
bandwidth: '{{ bandwidth }}'
instanceId: '{{ ACS::TaskLoopItem }}'
tags: '{{ eipTags }}'
ISP: '{{ ISP }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ instanceIds }}'
- Name: CompleteLifecycleActionForContinue
Action: 'ACS::ExecuteAPI'
Description:
en: Sets the lifecycle action to 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: Sets the lifecycle action to ABANDON.
Properties:
Service: ESS
API: CompleteLifecycleAction
Parameters:
RegionId: '{{ regionId }}'
LifecycleHookId: '{{ lifecycleHookId }}'
LifecycleActionToken: '{{ lifecycleActionToken }}'
LifecycleActionResult: ABANDON