is now a part of Cisco. Learn More

About Cisco

AMI Group Resource

Create a new Terraform template

Configure the batchly provider

                provider "batchly" 
                    tenant_url = "${var.tenant_url}"
                    api_key = "${var.api_key}"
                    secret_key = "${var.secret_key}" 

For Example: <>/<>

Provides a batchly AMI group resource

Example Usage

                # Create a batchly AMI group

                resource "batchly_aws_ami_group" "worker" 
                    name = "app_name"
                    account_resource_id = "A-XXXXXXX"
                    region = "us-east-1"
                    restrict_instance_type = true
                    minOnDemandCount = 0
                    minCount = 1
                    maxCount = 2
                    desired = 2
                    instance_type = "m4.large"
                    health_grace_period = 300
                    replace_unhealthy_instances = false
                    associate_public_ip = false

                        image_id = "ami-xxxxxxxx"
                        key_pair = "pemfile_name"
                        security_group_ids = ["sg-xxxxxxxx"]
                        load_balancers = ["elb_name"]
                        target_arns = ["target_arn"]

                        policy_name = "policy 1"
                        policy_type = "ScaleUp"
                        metric_name = "CPUUtilization"
                        statistic = "average"
                        unit = "percent"
                        threshold = 80
                        adjustment = 1
                        namespace = "AWS/EC2"
                        period = 300
                        evaluation_periods = 2
                        cooldown = 300

Argument Reference

  • name - (Required) Name of the asg job in batchly to be created.

  • region - (Required) aws region.

  • account_resource_id - (Required) The resource id created while adding an account in batchly.

  • restrict_instance_type - (Required) To restrict the instance type as specified in the launch configuration of the asg used.

  • minOnDemandCount - (Required) The minimum number of on demand instances the group should have at any time.

  • minCount - (Required) minOnDemandCount + no of minimum spot instances to run.

  • maxCount - (Required) The maximum number of instances the group should have at any time.

  • desired - (Required) The desired number of instances the group should have at any time.

  • health_grace_period - (Optional) The time in minutes an instance should wait before any user-data scripts executes in other words the instance is considered healthy.

  • instance_type - (Required) The instance type that needs to be launched to maintain min count of the desired state.

  • vpc_id - (Optional) The VPC id that needs to be associated with the job.

  • subnets - (Optional) The subnet id’s where the instances needs to be launched.

  • replace_unhealthy_instances - (Required) To replace the unhealthy instances behind elb’s or not.

  • associate_public_ip - (Required) To associate a public ip to the launched instances or not.

  • suspend_scaling_operations - (Optional) To suspend the scaling policies or not.

  • launch_specification - (Required) Describes the launch specification for an instance.

  • image_id - (Required) The ID of the AMI used to launch the instance.

  • key_pair - (Optional) The key name that should be used for the instance.

  • security_group_ids - (Required) list of security group ids.

  • user_data - (Optional) The user data to provide when launching the instance.

  • iam_instance_profile - (Optional) The ARN of an IAM instance profile to associate with launched instances.

  • load_balancers - (Optional) Registers each instance with the specified Elastic Load Balancers.

  • target_arns- (Optional) Registers each instance with the specified target arns.

Scaling Policies (Optional)

Each scaling_policy supports the following:

  • namespace - (Required) The namespace for the alarm’s associated metric.

  • metric_name - (Required) The name of the metric, with or without spaces.

  • threshold - (Required) The value against which the specified statistic is compared.

  • policy_name - (Required) Unique name for the policy.

  • policy_type - (Required) The name of the policy (ScaleUp/ScaleDown).

  • statistic - (Required) The metric statistics to return. For information about specific statistics go to Statistics in the Amazon CloudWatch Developer Guide.

  • unit - (Required) The unit for the alarm’s associated metric.

  • adjustment - (Required) The number of instances to add/remove to/from the target capacity when scale is needed.

  • period - (Required) The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60.

  • evaluation_periods - (Required) The number of periods over which data is compared to the specified threshold.

  • cooldown - (Optional) The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start. If this parameter is not specified, the default cooldown period for the group applies.

  • dimensions - (Optional) A mapping of dimensions describing qualities of the metric.