Allocates and attaches EIPs to ECS instances during Auto Scaling scale-out events via a lifecycle hook.
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 EIPs and attach them to ECS instances. Supports scale-out events only.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
|
Parameter |
Description |
Type |
Required |
Default value |
Limit |
|
internetChargeType |
EIP billing method. |
String |
No |
PayByBandwidth |
|
|
bandwidth |
Peak EIP bandwidth. |
Number |
No |
5 |
|
|
regionId |
Region ID. |
String |
No |
${regionId} |
|
|
instanceIds |
ECS instance IDs. |
List |
No |
['${instanceIds}'] |
|
|
eipTags |
EIP tags. |
Json |
No |
[{'Key': 'oos_generate', 'Value': '{{ACS::ExecutionId}}'}] |
|
|
ISP |
EIP line type. |
String |
No |
BGP |
|
|
lifecycleHookId |
Lifecycle hook ID. |
String |
No |
${lifecycleHookId} |
|
|
lifecycleActionToken |
Rate Control |
String |
No |
${lifecycleActionToken} |
|
|
rateControl |
Rate control settings. |
Json |
No |
{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 5} |
|
|
OOSAssumeRole |
RAM role assumed by OOS. |
String |
No |
OOSServiceRole |
Output parameters
None
Required permissions
{
"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