Skip to content

Commit f67a01a

Browse files
committed
refactor(asg): accept protect_from_scale_in as a variable for the autoscaling group
1 parent 231eedc commit f67a01a

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

modules/asg/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ No modules.
4747
| <a name="input_max_size"></a> [max\_size](#input\_max\_size) | Max. size for the Autoscaling group | `number` | n/a | yes |
4848
| <a name="input_min_size"></a> [min\_size](#input\_min\_size) | Min. size for the Autoscaling group | `number` | n/a | yes |
4949
| <a name="input_name"></a> [name](#input\_name) | Name of the Autoscaling Group | `string` | n/a | yes |
50+
| <a name="input_protect_from_scale_in"></a> [protect\_from\_scale\_in](#input\_protect\_from\_scale\_in) | Whether to enable protection for Autoscaling group from scaling in instances | `bool` | `false` | no |
5051
| <a name="input_tags"></a> [tags](#input\_tags) | Resources Tags for Autoscaling group | `map(any)` | `{}` | no |
5152
| <a name="input_vpc_zone_identifier"></a> [vpc\_zone\_identifier](#input\_vpc\_zone\_identifier) | Identifiers of the VPC Subnets | `list(string)` | n/a | yes |
5253

modules/asg/main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ resource "aws_autoscaling_group" "this" {
66
name = var.name
77
vpc_zone_identifier = var.vpc_zone_identifier
88

9-
desired_capacity = var.desired_capacity
10-
min_size = var.min_size
11-
max_size = var.max_size
9+
desired_capacity = var.desired_capacity
10+
min_size = var.min_size
11+
max_size = var.max_size
12+
protect_from_scale_in = try(var.protect_from_scale_in, null)
1213

1314
health_check_type = "EC2"
1415

modules/asg/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ variable "vpc_zone_identifier" {
1313
}
1414
}
1515

16+
variable "protect_from_scale_in" {
17+
description = "Whether to enable protection for Autoscaling group from scaling in instances"
18+
type = bool
19+
default = false
20+
}
21+
1622
variable "desired_capacity" {
1723
description = "Desired capacity for the Autoscaling group"
1824
type = number

0 commit comments

Comments
 (0)