This topic describes how to use a lifecycle hook to put ECS instances into the wait state and then use an Operation Orchestration Service (OOS) template to automatically add or remove the instances to or from the whitelist of an ApsaraDB for MongoDB (MongoDB) instance.
Prerequisites
- Before you perform the operations provided in the tutorial, you must have registered an Alibaba Cloud account. To create an Alibaba Cloud account, click Create a new Alibaba Cloud account.
- A scaling group is created and enabled.
- A MongoDB instance is created.
- A RAM role is created for OOS. For more information, see Grant RAM permission for OOS.
Note The OOSServiceRole RAM role is used in this example. You can also use other custom RAM roles, but you must make sure that the used RAM role has the permissions required to execute OOS templates.
Background information
Procedure
- Step 1: Grant OOS permissions to the RAM user
- Step 2: Create a lifecycle hook for scale-out events and trigger a scale-out event
- Step 3: View the whitelist of the MongoDB instance
- Step 4 (optional): View the OOS execution status
Step 1: Grant OOS permissions to the RAM user
You must be granted the permissions required to execute OOS templates. Resources of ECS, Auto Scaling, and MongoDB are involved when the O&M operations specified in the ACS-ESS-LifeCycleModifyMongoDBIPWhitelist template are performed.
- Log on to the RAM console.
- Create a policy.
- Attach the policy to the OOSServiceRole RAM role.
Step 2: Create a lifecycle hook for scale-out events and trigger a scale-out event
Step 3: View the whitelist of the MongoDB instance
Step 4 (optional): View the OOS execution status
FAQ
- Error message: Forbidden.Unauthorized message: A required authorization for the specified action
is not supplied.
Solution: Check whether you have granted the required permissions to the OOSServiceRole RAM role, such as the sample permissions in Step 1. You must grant required permissions to the OOSServiceRole RAM role to make sure that OOS can manage the resources that are involved in OOS templates.
- Error message: Forbidden.RAM message: User not authorized to operate on the specified resource, or
this API doesn't support RAM.
Solution: Check whether you have granted the required permissions to the OOSServiceRole RAM role, such as the sample permissions in Step 1. You must grant required permissions to the OOSServiceRole RAM role to make sure that OOS can manage the resources that are involved in OOS templates.
- Error message: LifecycleHookIdAndLifecycleActionToken.Invalid message: The specified lifecycleActionToken
and lifecycleActionId you provided does not match any in process lifecycle action.
Solution: Estimate the timeout period of the lifecycle hook to make sure that the O&M task that is specified in the OOS template can be complete within the timeout period.