This module creates one or more autoscaling groups.
module "asg" {
source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_asg//?ref=v0.12.4"
ec2_os = "amazon"
name = "my_asg"
security_groups = ["${module.sg.private_web_security_group_id}"]
subnets = ["${module.vpc.private_subnets}"]
}
Full working references are available at examples
Using aws-terraform-cloudwatch_alarm to create the following CloudWatch Alarms:
- group_terminating_instances
Several changes were required while adding terraform 0.12 compatibility. The following changes should
made when upgrading from a previous release to version 0.12.0 or higher.
The following module variables were updated to better meet current Rackspace style guides:
security_group_list
->security_groups
resource_name
->name
The following variables are no longer neccessary and were removed
additional_ssm_bootstrap_step_count
install_scaleft_agent
Several new variables were introduced to provide existing functionality, with a simplified format. The original formmating was also retained to allow easier transition.
New variables tags
and tags_asg
were added to replace the functionality of the additional_tags
variable. tags
allows setting tags on all resources, while tags_asg
sets tags only on the ASG itself. additional_tags
will continue to work as expected, but will be removed in a future release.
New variable ssm_bootstrap_list
was added to allow setting the SSM association steps using objects instead of strings, allowing easier linting and formatting of these lines. The additional_ssm_bootstrap_list
variable will continue to work, but will be deprecated in a future release.
Name | Version |
---|---|
aws | >= 2.1.0 |
null | n/a |
template | n/a |
Name | Description | Type | Default | Required |
---|---|---|---|---|
additional_ssm_bootstrap_list | A list of maps consisting of main step actions, to be appended to SSM associations. Please see usage.tf.example in this repo for examples. (DEPRECATED) This variable will be removed in future releases in favor of the ssm_bootstrap_list variable. |
list(map(string)) |
[] |
no |
additional_tags | Additional tags to be added to the ASG instance(s). Format: list of maps. Please see usage.tf.example in this repo for examples. (DEPRECATED) This variable will be removed in future releases in favor of the tags and tags_asg variables. |
list(map(string)) |
[] |
no |
asg_count | Number of identical ASG's to deploy | string |
"1" |
no |
asg_wait_for_capacity_timeout | A maximum duration that Terraform should wait for ASG instances to be healthy before timing out. | string |
"10m" |
no |
backup_tag_value | Value of the 'Backup' tag, used to assign te EBSSnapper configuration | string |
"False" |
no |
cloudwatch_log_retention | The number of days to retain Cloudwatch Logs for this instance. | string |
"30" |
no |
custom_cw_agent_config_ssm_param | SSM Parameter Store name that contains a custom CloudWatch agent configuration that you would like to use as an alternative to the default provided. | string |
"" |
no |
cw_high_evaluations | The number of periods over which data is compared to the specified threshold. | string |
"3" |
no |
cw_high_operator | Math operator used by CloudWatch for alarms and triggers. | string |
"GreaterThanThreshold" |
no |
cw_high_period | Time the specified statistic is applied. Must be in seconds that is also a multiple of 60. | string |
"60" |
no |
cw_high_threshold | The value against which the specified statistic is compared. | string |
"60" |
no |
cw_low_evaluations | The number of periods over which data is compared to the specified threshold. | string |
"3" |
no |
cw_low_operator | Math operator used by CloudWatch for alarms and triggers. | string |
"LessThanThreshold" |
no |
cw_low_period | Time the specified statistic is applied. Must be in seconds that is also a multiple of 60. | string |
"300" |
no |
cw_low_threshold | The value against which the specified statistic is compared. | string |
"30" |
no |
cw_scaling_metric | The metric to be used for scaling. | string |
"CPUUtilization" |
no |
detailed_monitoring | Enable Detailed Monitoring? true or false | bool |
true |
no |
ec2_os | Intended Operating System/Distribution of Instance. Valid inputs are: amazon , amazon2 , amazoneks , amazonecs , rhel6 , rhel7 , rhel8 , centos6 , centos7 , ubuntu14 , ubuntu16 , ubuntu18 , windows2012r2 , windows2016 , windows2019 |
string |
n/a | yes |
ec2_scale_down_adjustment | Number of EC2 instances to scale down by at a time. Positive numbers will be converted to negative. | string |
"-1" |
no |
ec2_scale_down_cool_down | Time in seconds before any further trigger-related scaling can occur. | string |
"60" |
no |
ec2_scale_up_adjustment | Number of EC2 instances to scale up by at a time. | string |
"1" |
no |
ec2_scale_up_cool_down | Time in seconds before any further trigger-related scaling can occur. | string |
"60" |
no |
enable_ebs_optimization | Use EBS Optimized? true or false | bool |
false |
no |
enable_rolling_updates | Should this autoscaling group be targeted by the ASG Instance Replacement tool to ensure all instances are using thelatest launch configuration. | bool |
true |
no |
enable_scaling_actions | Should this autoscaling group be configured with scaling alarms to manage the desired count. Set this variable to false if another process will manage the desired count, such as EKS Cluster Autoscaler. | bool |
true |
no |
enable_scaling_notification | true or false. If 'scaling_notification_topic' is set to a non-empty string, this must be set to true. Otherwise, set to false. This variable exists due to a terraform limitation with using count and computed values as conditionals | bool |
false |
no |
enabled_asg_metrics | List of ASG metrics desired. This can only contain the following values: GroupDesiredCapacity , GroupInServiceCapacity , GroupPendingCapacity , GroupMinSize , GroupMaxSize , GroupInServiceInstances , GroupPendingInstances , GroupStandbyInstances , GroupStandbyCapacity , GroupTerminatingCapacity , GroupTerminatingInstances , GroupTotalCapacity , GroupTotalInstances . |
list(string) |
[] |
no |
encrypt_primary_ebs_volume | Encrypt root EBS Volume? true or false | bool |
false |
no |
encrypt_secondary_ebs_volume | Encrypt secondary EBS Volume? true or false | bool |
false |
no |
environment | Application environment for which this network is being created. Preferred value are Development, Integration, PreProduction, Production, QA, Staging, or Test | string |
"Development" |
no |
final_userdata_commands | Commands to be given at the end of userdata for an instance. This should generally not include bootstrapping or ssm install. | string |
"" |
no |
health_check_grace_period | Number of seconds grace during which no autoscaling actions will be taken. | string |
"300" |
no |
health_check_type | Define the type of healthcheck for the AutoScaling group. | string |
"EC2" |
no |
image_id | The AMI ID to be used to build the EC2 Instance. If not provided, an AMI ID will be queried with an OS specified in variable ec2_os. | string |
"" |
no |
initial_userdata_commands | Commands to be given at the start of userdata for an instance. This should generally not include bootstrapping or ssm install. | string |
"" |
no |
install_codedeploy_agent | Install codedeploy agent on instance(s)? true or false | bool |
false |
no |
instance_profile_override | Optionally provide an instance profile. Any override profile should contain the permissions required for Rackspace support tooling to continue to function if required. | bool |
false |
no |
instance_profile_override_name | Provide an instance profile name. Any override profile should contain the permissions required for Rackspace support tooling to continue to function if required. To use this set instance_profile_override to true . |
string |
"" |
no |
instance_role_managed_policy_arn_count | The number of policy ARNs provided/set in variable 'instance_role_managed_policy_arns' | string |
"0" |
no |
instance_role_managed_policy_arns | List of IAM policy ARNs for the InstanceRole IAM role. IAM ARNs can be found within the Policies section of the AWS IAM console. e.g. ['arn:aws:iam::aws:policy/AmazonEC2FullAccess', 'arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore', 'arn:aws:iam::aws:policy/service-role/AmazonEC2SpotFleetRole'] | list(string) |
[] |
no |
instance_type | EC2 Instance Type e.g. 't2.micro' | string |
"t2.micro" |
no |
key_pair | Name of an existing EC2 KeyPair to enable SSH access to the instances. | string |
"" |
no |
load_balancer_names | A list of Classic load balancers associated with this Auto Scaling group. | list(string) |
[] |
no |
name | Name to be used for the provisioned EC2 instance(s), ASG(s), and other resources provisioned in this module | string |
n/a | yes |
notification_topic | List of SNS Topic ARNs to use for customer notifications. | list(string) |
[] |
no |
perform_ssm_inventory_tag | Determines whether Instance is tracked via System Manager Inventory. | string |
"True" |
no |
primary_ebs_volume_iops | Iops value required for use with io1 EBS volumes. This value should be 3 times the EBS volume size | string |
"0" |
no |
primary_ebs_volume_size | EBS Volume Size in GB | string |
"60" |
no |
primary_ebs_volume_type | EBS Volume Type. e.g. gp2, io1, st1, sc1 | string |
"gp2" |
no |
provide_custom_cw_agent_config | Set to true if a custom cloudwatch agent configuration has been provided in variable custom_cw_agent_config_ssm_param. | bool |
false |
no |
rackspace_alarms_enabled | Specifies whether alarms will create a Rackspace ticket. Ignored if rackspace_managed is set to false. | bool |
false |
no |
rackspace_managed | Boolean parameter controlling if instance will be fully managed by Rackspace support teams, created CloudWatch alarms that generate tickets, and utilize Rackspace managed SSM documents. | bool |
true |
no |
scaling_max | The maximum size of the Auto Scaling group. | string |
"2" |
no |
scaling_min | The minimum count of EC2 instances in the Auto Scaling group. | string |
"1" |
no |
scaling_notification_topic | SNS Topic ARN to notify if there are any scaling operations. OPTIONAL | string |
"" |
no |
secondary_ebs_volume_existing_id | The Snapshot ID of an existing EBS volume you want to use for the secondary volume. i.e. snap-0ad8580e3ac34a9f1 | string |
"" |
no |
secondary_ebs_volume_iops | Iops value required for use with io1 EBS volumes. This value should be 3 times the EBS volume size | string |
"0" |
no |
secondary_ebs_volume_size | EBS Volume Size in GB | string |
"" |
no |
secondary_ebs_volume_type | EBS Volume Type. e.g. gp2, io1, st1, sc1 | string |
"gp2" |
no |
security_groups | A list of EC2 security IDs to assign to this resource. | list(string) |
n/a | yes |
ssm_association_refresh_rate | A cron or rate pattern to define the SSM Association refresh schedule, defaulting to once per day. See https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-cron.html for more details. Schedule can be disabled by providing an empty string. | string |
"rate(1 day)" |
no |
ssm_bootstrap_list | A list of objects consisting of actions, to be appended to SSM associations. Please see usage.tf.example in this repo for examples. | any |
[] |
no |
ssm_patching_group | Group ID to be used by System Manager for Patching | string |
"" |
no |
subnets | List of subnets for Application. e.g. ['subnet-8da92df7', 'subnet-9e5dc5f6', 'subnet-497eaf33'] | list(string) |
n/a | yes |
tags | A map of tags to apply to all resources. These tags will all be propagated to ASG instances and set on all other resources. | map(string) |
{} |
no |
tags_asg | A map of tags to apply to the ASG itself. These tags will not be propagated to ASG instances or set on any other resources. | map(string) |
{} |
no |
target_group_arns | A list of Amazon Resource Names (ARN) of target groups to associate with the Auto Scaling group. | list(string) |
[] |
no |
tenancy | The placement tenancy for EC2 devices. e.g. host, default, dedicated | string |
"default" |
no |
terminated_instances | Specifies the maximum number of instances that can be terminated in a six hour period without generating a Cloudwatch Alarm. | string |
"30" |
no |
Name | Description |
---|---|
asg_arn_list | List of ASG ARNs |
asg_image_id | Image ID used for EC2 provisioning |
asg_name_list | List of ASG names |
iam_role | Name of the created IAM Instance role. |