ScalingGroup

class ScalingGroup : KotlinCustomResource

Provides a ESS scaling group resource which is a collection of ECS instances with the same application scenarios. It defines the maximum and minimum numbers of ECS instances in the group, and their associated Server Load Balancer instances, RDS instances, and other attributes.

NOTE: You can launch an ESS scaling group for a VPC network via specifying parameter vswitch_ids. For information about ess scaling rule, see CreateScalingGroup. NOTE: Available since v1.39.0.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.inputs.GetInstanceTypesArgs;
import com.pulumi.alicloud.ecs.inputs.GetImagesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.ecs.SecurityGroup;
import com.pulumi.alicloud.ecs.SecurityGroupArgs;
import com.pulumi.alicloud.ecs.SecurityGroupRule;
import com.pulumi.alicloud.ecs.SecurityGroupRuleArgs;
import com.pulumi.alicloud.ess.ScalingGroup;
import com.pulumi.alicloud.ess.ScalingGroupArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var name = config.get("name").orElse("terraform-example");
final var defaultZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableDiskCategory("cloud_efficiency")
.availableResourceCreation("VSwitch")
.build());
final var defaultInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
.availabilityZone(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.cpuCoreCount(2)
.memorySize(4)
.build());
final var defaultImages = EcsFunctions.getImages(GetImagesArgs.builder()
.nameRegex("^ubuntu_18.*64")
.mostRecent(true)
.owners("system")
.build());
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.vpcName(name)
.cidrBlock("172.16.0.0/16")
.build());
var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
.vpcId(defaultNetwork.id())
.cidrBlock("172.16.0.0/24")
.zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.vswitchName(name)
.build());
var defaultSecurityGroup = new SecurityGroup("defaultSecurityGroup", SecurityGroupArgs.builder()
.vpcId(defaultNetwork.id())
.build());
var defaultSecurityGroupRule = new SecurityGroupRule("defaultSecurityGroupRule", SecurityGroupRuleArgs.builder()
.type("ingress")
.ipProtocol("tcp")
.nicType("intranet")
.policy("accept")
.portRange("22/22")
.priority(1)
.securityGroupId(defaultSecurityGroup.id())
.cidrIp("172.16.0.0/24")
.build());
var default2 = new Switch("default2", SwitchArgs.builder()
.vpcId(defaultNetwork.id())
.cidrBlock("172.16.1.0/24")
.zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.vswitchName(String.format("%s-bar", name))
.build());
var defaultScalingGroup = new ScalingGroup("defaultScalingGroup", ScalingGroupArgs.builder()
.minSize(1)
.maxSize(1)
.scalingGroupName(name)
.defaultCooldown(20)
.vswitchIds(
defaultSwitch.id(),
default2.id())
.removalPolicies(
"OldestInstance",
"NewestInstance")
.build());
}
}

Module Support

You can use to the existing autoscaling module to create a scaling group, configuration and lifecycle hook one-click.

Import

ESS scaling group can be imported using the id, e.g.

$ pulumi import alicloud:ess/scalingGroup:ScalingGroup example asg-abc123456

Properties

Link copied to clipboard
val dbInstanceIds: Output<List<String>>?

If an RDS instance is specified in the scaling group, the scaling group automatically attaches the Intranet IP addresses of its ECS instances to the RDS access whitelist.

Link copied to clipboard
val defaultCooldown: Output<Int>?

Default cool-down time (in seconds) of the scaling group. Value range: 0, 86400. The default value is 300s.

Link copied to clipboard
val desiredCapacity: Output<Int>?

Expected number of ECS instances in the scaling group. Value range: min_size, max_size.

Link copied to clipboard

Specifies whether the scaling group deletion protection is enabled. true or false, Default value: false.

Link copied to clipboard
val groupType: Output<String>

Resource type within scaling group. Optional values: ECS, ECI. Default to ECS.

Link copied to clipboard
val healthCheckType: Output<String>

Resource type within scaling group. Optional values: ECS, NONE. Default to ECS.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val launchTemplateId: Output<String>?

Instance launch template ID, scaling group obtains launch configuration from instance launch template, see Launch Template. Creating scaling group from launch template enable group automatically.

Link copied to clipboard

The version number of the launch template. Valid values are the version number, Latest, or Default, Default value: Default.

Link copied to clipboard
val loadbalancerIds: Output<List<String>>?

If a Server Load Balancer instance is specified in the scaling group, the scaling group automatically attaches its ECS instances to the Server Load Balancer instance.

Link copied to clipboard
val maxSize: Output<Int>

Maximum number of ECS instances in the scaling group. Value range: 0, 2000. NOTE: From version 1.204.1, max_size can be set to 2000.

Link copied to clipboard
val minSize: Output<Int>

Minimum number of ECS instances in the scaling group. Value range: 0, 2000. NOTE: From version 1.204.1, min_size can be set to 2000.

Link copied to clipboard
val multiAzPolicy: Output<String>?

Multi-AZ scaling group ECS instance expansion and contraction strategy. PRIORITY, BALANCE or COST_OPTIMIZED(Available in 1.54.0+).

Link copied to clipboard

The minimum amount of the Auto Scaling group's capacity that must be fulfilled by On-Demand Instances. This base portion is provisioned first as your group scales.

Link copied to clipboard

Controls the percentages of On-Demand Instances and Spot Instances for your additional capacity beyond OnDemandBaseCapacity.

Link copied to clipboard

Set or unset instances within group into protected status.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

RemovalPolicy is used to select the ECS instances you want to remove from the scaling group when multiple candidates for removal exist. Optional values:

Link copied to clipboard
val scalingGroupName: Output<String>?

Name shown for the scaling group, which must contain 2-64 characters (English or Chinese), starting with numbers, English letters or Chinese characters, and can contain numbers, underscores _, hyphens -, and decimal points .. If this parameter is not specified, the default value is ScalingGroupId.

Link copied to clipboard
val spotInstancePools: Output<Int>

The number of Spot pools to use to allocate your Spot capacity. The Spot pools is composed of instance types of lowest price.

Link copied to clipboard

Whether to replace spot instances with newly created spot/onDemand instance when receive a spot recycling message.

Link copied to clipboard
val tags: Output<Map<String, Any>>?

A mapping of tags to assign to the resource.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val vswitchId: Output<String>?

It has been deprecated from version 1.7.1 and new field 'vswitch_ids' replaces it.

Link copied to clipboard
val vswitchIds: Output<List<String>>?

List of virtual switch IDs in which the ecs instances to be launched.