Skip to content

Commit e4fa0cd

Browse files
committed
chore: @gberenice's feedback + bumps 1.0 tf + time provider
1 parent 4d6d237 commit e4fa0cd

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ Use [the awesome `gossm` project](https://github.com/gjbae1212/gossm).
7373

7474
| Name | Version |
7575
|------|---------|
76-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
76+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
7777
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
78+
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.7 |
7879

7980
## Providers
8081

8182
| Name | Version |
8283
|------|---------|
83-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
84+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.37.0 |
8485

8586
## Modules
8687

@@ -131,7 +132,7 @@ Use [the awesome `gossm` project](https://github.com/gjbae1212/gossm).
131132
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
132133
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
133134
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
134-
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The instance type to use for the SSM Agent EC2 Instnace. | `string` | `"t3.nano"` | no |
135+
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The instance type to use for the SSM Agent EC2 instance. | `string` | `"t4g.nano"` | no |
135136
| <a name="input_key_pair_name"></a> [key\_pair\_name](#input\_key\_pair\_name) | The name of the key-pair to associate with the SSM Agent instances. This can be (and probably should) left empty unless you specifically plan to use `AWS-StartSSHSession`. | `string` | `null` | no |
136137
| <a name="input_label_key_case"></a> [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.<br>Does not affect keys of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
137138
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
@@ -146,8 +147,10 @@ Use [the awesome `gossm` project](https://github.com/gjbae1212/gossm).
146147
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
147148
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
148149
| <a name="input_permissions_boundary"></a> [permissions\_boundary](#input\_permissions\_boundary) | The ARN of the permissions boundary that will be applied to the SSM Agent role. | `string` | `""` | no |
150+
| <a name="input_protect_from_scale_in"></a> [protect\_from\_scale\_in](#input\_protect\_from\_scale\_in) | Allows setting instance protection for scale in actions on the ASG. | `bool` | `false` | no |
149151
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
150152
| <a name="input_region"></a> [region](#input\_region) | The region to deploy the S3 bucket for session logs. If not supplied, the module will use the current region. | `string` | `""` | no |
153+
| <a name="input_scale_in_protected_instances"></a> [scale\_in\_protected\_instances](#input\_scale\_in\_protected\_instances) | Behavior when encountering instances protected from scale in are found. Available behaviors are Refresh, Ignore, and Wait. Default is Ignore. | `string` | `"Ignore"` | no |
151154
| <a name="input_session_logging_bucket_name"></a> [session\_logging\_bucket\_name](#input\_session\_logging\_bucket\_name) | The name of the S3 Bucket to ship session logs to. This will remove creation of an independent session logging bucket. This is only relevant if the session\_logging\_enabled variable is `true`. | `string` | `""` | no |
152155
| <a name="input_session_logging_enabled"></a> [session\_logging\_enabled](#input\_session\_logging\_enabled) | To enable CloudWatch and S3 session logging or not. Note this does not apply to SSH sessions as AWS cannot log those sessions. | `bool` | `true` | no |
153156
| <a name="input_session_logging_encryption_enabled"></a> [session\_logging\_encryption\_enabled](#input\_session\_logging\_encryption\_enabled) | To enable CloudWatch and S3 session logging encryption or not. | `bool` | `true` | no |

main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ resource "aws_autoscaling_group" "default" {
319319
min_size = var.min_size
320320
desired_capacity = var.desired_capacity
321321

322-
# We don't care to protect from scale in by default, as we want to roll instances frequently
323-
protect_from_scale_in = false
322+
# By default, we don't care to protect from scale in as we want to roll instances frequently
323+
protect_from_scale_in = var.protect_from_scale_in
324324

325325
vpc_zone_identifier = var.subnet_ids
326326

@@ -341,7 +341,8 @@ resource "aws_autoscaling_group" "default" {
341341
strategy = "Rolling"
342342
triggers = ["tag"]
343343
preferences {
344-
min_healthy_percentage = 50
344+
scale_in_protected_instances = var.scale_in_protected_instances
345+
min_healthy_percentage = 50
345346
}
346347
}
347348

variables.tf

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ variable "permissions_boundary" {
1919
####################
2020

2121
variable "instance_type" {
22-
default = "t3.nano"
22+
default = "t4g.nano"
2323
type = string
24-
description = "The instance type to use for the SSM Agent EC2 Instnace."
24+
description = "The instance type to use for the SSM Agent EC2 instance."
2525
}
2626

2727
variable "ami" {
@@ -166,3 +166,20 @@ variable "desired_capacity" {
166166
type = number
167167
default = 1
168168
}
169+
170+
variable "protect_from_scale_in" {
171+
description = "Allows setting instance protection for scale in actions on the ASG."
172+
type = bool
173+
default = false
174+
}
175+
176+
variable "scale_in_protected_instances" {
177+
description = "Behavior when encountering instances protected from scale in are found. Available behaviors are Refresh, Ignore, and Wait. Default is Ignore."
178+
type = string
179+
default = "Ignore"
180+
181+
validation {
182+
condition = contains(["Refresh", "Ignore", "Wait"], var.scale_in_protected_instances)
183+
error_message = "scale_in_protected_instances must be one of Refresh, Ignore, or Wait"
184+
}
185+
}

versions.tf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
terraform {
2-
required_version = ">= 0.13.0"
2+
required_version = ">= 1.0"
33

44
required_providers {
5-
aws = ">= 5.0"
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.0"
8+
}
9+
10+
time = {
11+
source = "hashicorp/time"
12+
version = ">= 0.7"
13+
}
614
}
715
}

0 commit comments

Comments
 (0)