Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Use launch_template_id instead of launch_template_name, raise MSV of AWS provider and Terraform to 5.0 and 1.0 respectively #204

Merged
merged 10 commits into from
Oct 9, 2023
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ No modules.
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The type of the instance. If present then `instance_requirements` cannot be present | `string` | `null` | no |
| <a name="input_kernel_id"></a> [kernel\_id](#input\_kernel\_id) | The kernel ID | `string` | `null` | no |
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | The key name that should be used for the instance | `string` | `null` | no |
| <a name="input_launch_template"></a> [launch\_template](#input\_launch\_template) | Name of an existing launch template to be used (created outside of this module) | `string` | `null` | no |
| <a name="input_launch_template_description"></a> [launch\_template\_description](#input\_launch\_template\_description) | Description of the launch template | `string` | `null` | no |
| <a name="input_launch_template_id"></a> [launch\_template\_id](#input\_launch\_template\_id) | ID of an existing launch template to be used (created outside of this module) | `string` | `null` | no |
| <a name="input_launch_template_name"></a> [launch\_template\_name](#input\_launch\_template\_name) | Name of launch template to be created | `string` | `""` | no |
| <a name="input_launch_template_use_name_prefix"></a> [launch\_template\_use\_name\_prefix](#input\_launch\_template\_use\_name\_prefix) | Determines whether to use `launch_template_name` as is or create a unique name beginning with the `launch_template_name` as the prefix | `bool` | `true` | no |
| <a name="input_launch_template_version"></a> [launch\_template\_version](#input\_launch\_template\_version) | Launch template version. Can be version number, `$Latest`, or `$Default` | `string` | `null` | no |
Expand Down
2 changes: 1 addition & 1 deletion examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ module "external" {

# Launch template
create_launch_template = false
launch_template = aws_launch_template.this.name
launch_template_id = aws_launch_template.this.id

tags = local.tags
}
Expand Down
14 changes: 7 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ locals {
create = var.create && var.putin_khuylo

launch_template_name = coalesce(var.launch_template_name, var.name)
launch_template = var.create_launch_template ? aws_launch_template.this[0].name : var.launch_template
launch_template_id = var.create_launch_template ? aws_launch_template.this[0].id : var.launch_template_id
launch_template_version = var.create_launch_template && var.launch_template_version == null ? aws_launch_template.this[0].latest_version : var.launch_template_version

asg_tags = merge(
Expand Down Expand Up @@ -353,7 +353,7 @@ resource "aws_autoscaling_group" "this" {
for_each = var.use_mixed_instances_policy ? [] : [1]

content {
name = local.launch_template
id = local.launch_template_id
version = local.launch_template_version
}
}
Expand Down Expand Up @@ -434,8 +434,8 @@ resource "aws_autoscaling_group" "this" {

launch_template {
launch_template_specification {
launch_template_name = local.launch_template
version = local.launch_template_version
launch_template_id = local.launch_template_id
version = local.launch_template_version
}

dynamic "override" {
Expand Down Expand Up @@ -504,7 +504,7 @@ resource "aws_autoscaling_group" "idc" {
for_each = var.use_mixed_instances_policy ? [] : [1]

content {
name = local.launch_template
id = local.launch_template_id
version = local.launch_template_version
}
}
Expand Down Expand Up @@ -585,8 +585,8 @@ resource "aws_autoscaling_group" "idc" {

launch_template {
launch_template_specification {
launch_template_name = local.launch_template
version = local.launch_template_version
launch_template_id = local.launch_template_id
version = local.launch_template_version
}

dynamic "override" {
Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ variable "instance_name" {
default = ""
}

variable "launch_template" {
description = "Name of an existing launch template to be used (created outside of this module)"
variable "launch_template_id" {
description = "ID of an existing launch template to be used (created outside of this module)"
type = string
default = null
}
Expand Down