Skip to content

Commit b514996

Browse files
sethpollackspr-mweber3
authored andcommitted
feat: Add create_autoscaling_group option and extra outputs (terraform-aws-modules#2067)
1 parent cc5ceb6 commit b514996

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

modules/self-managed-node-group/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ module "self_managed_node_group" {
9191
| <a name="input_cluster_version"></a> [cluster\_version](#input\_cluster\_version) | Kubernetes cluster version - used to lookup default AMI ID if one is not provided | `string` | `null` | no |
9292
| <a name="input_cpu_options"></a> [cpu\_options](#input\_cpu\_options) | The CPU options for the instance | `map(string)` | `null` | no |
9393
| <a name="input_create"></a> [create](#input\_create) | Determines whether to create self managed node group or not | `bool` | `true` | no |
94+
| <a name="input_create_autoscaling_group"></a> [create\_autoscaling\_group](#input\_create\_autoscaling\_group) | Determines whether to create autoscaling group or not | `bool` | `true` | no |
9495
| <a name="input_create_iam_instance_profile"></a> [create\_iam\_instance\_profile](#input\_create\_iam\_instance\_profile) | Determines whether an IAM instance profile is created or to use an existing IAM instance profile | `bool` | `true` | no |
9596
| <a name="input_create_launch_template"></a> [create\_launch\_template](#input\_create\_launch\_template) | Determines whether to create launch template or not | `bool` | `true` | no |
9697
| <a name="input_create_schedule"></a> [create\_schedule](#input\_create\_schedule) | Determines whether to create autoscaling group schedule or not | `bool` | `true` | no |
@@ -194,10 +195,12 @@ module "self_managed_node_group" {
194195
| <a name="output_iam_role_arn"></a> [iam\_role\_arn](#output\_iam\_role\_arn) | The Amazon Resource Name (ARN) specifying the IAM role |
195196
| <a name="output_iam_role_name"></a> [iam\_role\_name](#output\_iam\_role\_name) | The name of the IAM role |
196197
| <a name="output_iam_role_unique_id"></a> [iam\_role\_unique\_id](#output\_iam\_role\_unique\_id) | Stable and unique string identifying the IAM role |
198+
| <a name="output_image_id"></a> [image\_id](#output\_image\_id) | ID of the image |
197199
| <a name="output_launch_template_arn"></a> [launch\_template\_arn](#output\_launch\_template\_arn) | The ARN of the launch template |
198200
| <a name="output_launch_template_id"></a> [launch\_template\_id](#output\_launch\_template\_id) | The ID of the launch template |
199201
| <a name="output_launch_template_latest_version"></a> [launch\_template\_latest\_version](#output\_launch\_template\_latest\_version) | The latest version of the launch template |
200202
| <a name="output_platform"></a> [platform](#output\_platform) | Identifies if the OS platform is `bottlerocket`, `linux`, or `windows` based |
201203
| <a name="output_security_group_arn"></a> [security\_group\_arn](#output\_security\_group\_arn) | Amazon Resource Name (ARN) of the security group |
202204
| <a name="output_security_group_id"></a> [security\_group\_id](#output\_security\_group\_id) | ID of the security group |
205+
| <a name="output_user_data"></a> [user\_data](#output\_user\_data) | Base64 encoded user data |
203206
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/self-managed-node-group/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ locals {
263263
}
264264

265265
resource "aws_autoscaling_group" "this" {
266-
count = var.create ? 1 : 0
266+
count = var.create && var.create_autoscaling_group ? 1 : 0
267267

268268
name = var.use_name_prefix ? null : var.name
269269
name_prefix = var.use_name_prefix ? "${var.name}-" : null

modules/self-managed-node-group/outputs.tf

+10
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,13 @@ output "platform" {
145145
description = "Identifies if the OS platform is `bottlerocket`, `linux`, or `windows` based"
146146
value = var.platform
147147
}
148+
149+
output "image_id" {
150+
description = "ID of the image"
151+
value = try(data.aws_ami.eks_default[0].image_id, "")
152+
}
153+
154+
output "user_data" {
155+
description = "Base64 encoded user data"
156+
value = try(module.user_data.user_data, "")
157+
}

modules/self-managed-node-group/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ variable "launch_template_tags" {
266266
# Autoscaling group
267267
################################################################################
268268

269+
variable "create_autoscaling_group" {
270+
description = "Determines whether to create autoscaling group or not"
271+
type = bool
272+
default = true
273+
}
274+
269275
variable "name" {
270276
description = "Name of the Self managed Node Group"
271277
type = string

node_groups.tf

+2
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ module "self_managed_node_group" {
346346
cluster_ip_family = var.cluster_ip_family
347347

348348
# Autoscaling Group
349+
create_autoscaling_group = try(each.value.create_autoscaling_group, var.self_managed_node_group_defaults.create_autoscaling_group, true)
350+
349351
name = try(each.value.name, each.key)
350352
use_name_prefix = try(each.value.use_name_prefix, var.self_managed_node_group_defaults.use_name_prefix, true)
351353

0 commit comments

Comments
 (0)