» alicloud_ess_scaling_rule

Provides a ESS scaling rule resource.

» Example Usage

variable "name" {
  default = "essscalingruleconfig"
}

data "alicloud_zones" "default" {
  available_disk_category     = "cloud_efficiency"
  available_resource_creation = "VSwitch"
}

data "alicloud_instance_types" "default" {
  availability_zone = "${data.alicloud_zones.default.zones.0.id}"
  cpu_core_count    = 2
  memory_size       = 4
}

data "alicloud_images" "default" {
  name_regex  = "^ubuntu_14.*_64"
  most_recent = true
  owners      = "system"
}

resource "alicloud_vpc" "default" {
  name       = "${var.name}"
  cidr_block = "172.16.0.0/16"
}

resource "alicloud_vswitch" "default" {
  vpc_id            = "${alicloud_vpc.default.id}"
  cidr_block        = "172.16.0.0/24"
  availability_zone = "${data.alicloud_zones.default.zones.0.id}"
  name              = "${var.name}"
}

resource "alicloud_security_group" "default" {
  name   = "${var.name}"
  vpc_id = "${alicloud_vpc.default.id}"
}

resource "alicloud_security_group_rule" "default" {
  type              = "ingress"
  ip_protocol       = "tcp"
  nic_type          = "intranet"
  policy            = "accept"
  port_range        = "22/22"
  priority          = 1
  security_group_id = "${alicloud_security_group.default.id}"
  cidr_ip           = "172.16.0.0/24"
}

resource "alicloud_ess_scaling_group" "default" {
  min_size           = 1
  max_size           = 1
  scaling_group_name = "${var.name}"
  vswitch_ids        = ["${alicloud_vswitch.default.id}"]
  removal_policies   = ["OldestInstance", "NewestInstance"]
}

resource "alicloud_ess_scaling_configuration" "default" {
  scaling_group_id  = "${alicloud_ess_scaling_group.default.id}"
  image_id          = "${data.alicloud_images.default.images.0.id}"
  instance_type     = "${data.alicloud_instance_types.default.instance_types.0.id}"
  security_group_id = "${alicloud_security_group.default.id}"
  force_delete      = "true"
}

resource "alicloud_ess_scaling_rule" "default" {
  scaling_group_id = "${alicloud_ess_scaling_group.default.id}"
  adjustment_type  = "TotalCapacity"
  adjustment_value = 1
}

» Argument Reference

The following arguments are supported:

  • scaling_group_id - (Required) ID of the scaling group of a scaling rule.
  • adjustment_type - (Required) Adjustment mode of a scaling rule. Optional values:
    • QuantityChangeInCapacity: It is used to increase or decrease a specified number of ECS instances.
    • PercentChangeInCapacity: It is used to increase or decrease a specified proportion of ECS instances.
    • TotalCapacity: It is used to adjust the quantity of ECS instances in the current scaling group to a specified value.
  • adjustment_value - (Required) Adjusted value of a scaling rule. Value range:
    • QuantityChangeInCapacity:(0, 100] U (-100, 0]
    • PercentChangeInCapacity:[0, 10000] U [-10000, 0]
    • TotalCapacity:[0, 100]
  • scaling_rule_name - (Optional) Name shown for the scaling rule, which is a string containing 2 to 40 English or Chinese characters.
  • cooldown - (Optional) Cool-down time of a scaling rule. Value range: [0, 86,400], in seconds. The default value is empty.

» Attributes Reference

The following attributes are exported:

  • id - The scaling rule ID.

» Import

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

$ terraform import alicloud_ess_scalingrule.example abc123456