# AutoScaling Provides an E2E Cloud Auto Scaling Group (Scaler Group) resource. This resource allows you to provision and manage scalable compute node groups (scaler groups) on your E2E Cloud project. When applied, it creates a new scaler group with specified scaling policies, VPCs, and security groups. When destroyed, the scaler group is deleted. ## Example Usage ```hcl resource "e2e_scaler_group" "example" { project_id = "12345" # Enter your project id here location = "Delhi" name = "my-scaler-group" plan_name = "C3.8GB" # Enter your desired plan name here vm_image_name = "C3-8GB-142" # Enter your own saved image name here is_encryption_enabled = false encryption_passphrase = "" # optional ,only enter if is_encryption_enabled is true is_public_ip_required = true # optional,default is true vpc { name = "my-vpc" # Optional,enter your vpc name at time of creation or updation,enter active vpc name like VPC-455.separate nested blocks for each vpc } vpc { name = "my-vpc-2" } min_nodes = 2 max_nodes = 5 desired = 3 policy_type = "Default" # Optional ,enter this as Default while creating elastic policy policy { type = "CHANGE" adjust = 1 parameter = "CPU" operator = ">" value = "60" period_number = "3" period_seconds = "10" cooldown = "150" } policy { type = "CHANGE" adjust = -1 parameter = "CPU" operator = "<" value = "30" period_number = "3" period_seconds = "10" cooldown = "150" } scheduled_policy { type = "CARDINALITY" adjust = "4" recurrence = "0 12 * * *" } scheduled_policy { type = "CARDINALITY" adjust = "2" recurrence = "0 2 * * *" } security_group_ids = [101, 102] # Optional, Use this to update security groups,not at time of creation } ``` ## Schema ### Required Attributes - `project_id` (String): Your E2E Cloud project ID. - `location` (String): Data center location for the scaler group. - `name` (String): Name of the scaler group. - `plan_name` (String): Plan/instance type name (e.g., `"C3.8GB"`). - `vm_image_name` (String): Name of the VM image for nodes. - `is_encryption_enabled` (Boolean): Enable encryption on nodes. - `min_nodes` (Int): Minimum number of nodes in the scaler group. - `max_nodes` (Int): Maximum number of nodes allowed. - `desired` (Int): Desired node count at creation. ### Optional Attributes - `encryption_passphrase` (String): Passphrase for encryption (if enabled). - `is_public_ip_required` (Boolean, default: `true`): Whether nodes should have public IPs. - `vpc` (Set of nested blocks): One or more VPC blocks to attach by name. - `security_group_ids` (List of Int): Security Group IDs attached; supports updates post-creation. - `policy_type` (String): Scaling policy type (e.g., `"Default"`). Enter this as `Default` while creating elastic policy. - `provision_status` (String, default: `"Running"`): Scaler group state: `"Running"` or `"Stopped"`. - `policy` (List of Object): Elastic scaling policies controlling scaling behavior. Enter two blocks, one for scale-up and one for scale-down at designated times. - `scheduled_policy` (List of Object): Scheduled scaling policies using cron. Enter two blocks, one for scale-up and one for scale-down at designated times. ### Computed / Read-Only - `plan_id` (String): Internal plan ID resolved from `plan_name`. - `sku_id` (String): SKU ID, same as `plan_id`. - `slug_name` (String): Slug name of the plan. - `vm_image_id` (String): Internal VM image ID. - `vm_template_id` (Int): Template ID of the VM image. - `my_account_sg_id` (Int): Security Group ID attached at creation time. - `vpc` details including `network_id`, `ipv4_cidr`, `state`, and `subnets` with their `CIDRs` and IP usage. ## Nested Schema ### Elastic Policy (in policy list) - `type` (String): Policy type (e.g., `"cpu_usage"`). - `adjust` (Int): Adjustment amount for scaling. - `parameter` (String): Metric parameter (e.g., `"cpu"`). - `operator` (String): Comparison operator (`">"`, `"<"`, etc.). - `value` (String): Threshold value. - `period_number` (String): Number of periods to evaluate. - `period_seconds` (String): Duration (in seconds) of each period. - `cooldown` (String): Cooldown time after a scaling event. ### Scheduled Policy (in scheduled_policy list) - `type` (String): Policy type (e.g., `"schedule"`). - `adjust` (String): Adjustment amount (`+`/`-`). - `recurrence` (String): Cron expression defining schedule. ## Behavior and Usage Notes - Security Groups and Policy Guidelines - At creation, a single security group ID (`my_account_sg_id`) is attached (defaults if unset). - `security_group_ids` allows multiple SGs and supports add/remove post-creation. - Scaler group must be in "Running" state to update security groups. - At least one security group must remain attached. - VPCs can only be attached/detached when the scaler group is "Stopped". - Changes to is_public_ip_required can only be applied when the scaler group is "Stopped" and at least one VPC is attached. - Use provision_status to start or stop the scaler group ("Running" or "Stopped"). - Enter either two blocks of policy for elastic policy scale up and scale down, or two blocks of scheduled policy for scheduled policy scale up and scale down, or two blocks of both depending upon requirement. ---