This topic describes how to use a lifecycle hook to add ECS instances to or remove them from the whitelist of an ApsaraDB for Redis (Redis) instance.

Background information

A scaling group can be associated with Server Load Balancer (SLB) or ApsaraDB for RDS (RDS) instances, but cannot be associated with Redis instances. If your business data is stored in a Redis instance, you must manually add your ECS instances to or remove them from the whitelist of the Redis instance. This is time-consuming and inefficient. Operation Orchestration Service (OOS) is an automated operations service provided by Alibaba Cloud. You can use lifecycle hooks of Auto Scaling and OOS templates to automatically add ECS instances to or remove them from the whitelist of a Redis instance.

Procedure

  1. Log on to the Auto Scaling console.
  2. In the top navigation bar, select a region.
  3. You can use either of the following methods to open the details page of a scaling group.
    • In the Scaling Group Name/ID column, click a scaling group name.
    • Click Manage in the Actions column corresponding to a scaling group.
  4. In the left-side navigation pane, click Lifecycle Hooks.
  5. Click Create Lifecycle Hook.
  6. Configure parameters that are related to the whitelist of a Redis instance.
    1. In the Notification Method section, select OOS Template and then select Public Templates.
    2. Select ACS-ESS-LifeCycleModifyRedisIPWhitelist from the public template list.
      You can enter the keyword redis to search for the template.
    3. Click Configure Parameters.
    4. Configure parameters for the OOS template.
      Parameter Description
      dbInstanceId The ID of the Redis instance.
      modifyMode The specified operation type. It must be the same as that of the scaling activity.
      • Append: corresponds to the scale-out event, and specifies that the internal IP addresses of ECS instances are automatically added to the whitelist of the Redis instance.
      • Delete: corresponds to the scale-in event, and specifies that the internal IP addresses of ECS instances are automatically removed from the whitelist of the Redis instance.
      Permissions The permission to automatically add ECS instances to or remove them from the whitelist of the Redis instance. Default value: OOSServiceRole.

      You can create other RAM roles. For more information, see Grant RAM permission for OOS

  7. Click OK.
  8. Configure other required parameters for the lifecycle hook and click Create.
    For more information about other required parameters for a lifecycle hook, see Create a lifecycle hook.