From f51ab1333cb80ce0adcf92b4f9e5f8136a4823a2 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Sat, 6 May 2023 15:00:30 +0200 Subject: [PATCH 1/8] fix: implementation of cpu_options block --- examples/complete/main.tf | 89 ++++++++++++++++++++++++++++++++++++--- main.tf | 10 +++++ variables.tf | 6 +++ versions.tf | 2 +- 4 files changed, 101 insertions(+), 6 deletions(-) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 4d181936..bc446e5a 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -54,9 +54,10 @@ module "ec2_complete" { user_data_base64 = base64encode(local.user_data) user_data_replace_on_change = true - cpu_core_count = 2 # default 4 - cpu_threads_per_core = 1 # default 2 - + cpu_options = { + core_count = 2 + threads_per_core = 1 + } enable_volume_tags = false root_block_device = [ { @@ -244,8 +245,10 @@ module "ec2_spot_instance" { user_data_base64 = base64encode(local.user_data) - cpu_core_count = 2 # default 4 - cpu_threads_per_core = 1 # default 2 + cpu_options = { + core_count = 2 + threads_per_core = 1 + } enable_volume_tags = false root_block_device = [ @@ -334,6 +337,72 @@ resource "aws_ec2_capacity_reservation" "targeted" { instance_match_criteria = "targeted" } +################################################################################ +# EC2 Module - CPU Options +################################################################################ +module "ec2_cpu_options" { + source = "../../" + + name = "${local.name}-cpu-options" + + ami = data.aws_ami.amazon_linux_23.id + instance_type = "c6a.xlarge" # used to set core count below and test amd_sev_snp attribute + availability_zone = element(module.vpc.azs, 0) + subnet_id = element(module.vpc.private_subnets, 0) + vpc_security_group_ids = [module.security_group.security_group_id] + placement_group = aws_placement_group.web.id + associate_public_ip_address = true + disable_api_stop = false + + create_iam_instance_profile = true + iam_role_description = "IAM role for EC2 instance" + iam_role_policies = { + AdministratorAccess = "arn:aws:iam::aws:policy/AdministratorAccess" + } + + user_data_base64 = base64encode(local.user_data) + user_data_replace_on_change = true + + cpu_options = { + core_count = 2 + threads_per_core = 1 + amd_sev_snp = "enabled" + } + enable_volume_tags = false + root_block_device = [ + { + encrypted = true + volume_type = "gp3" + throughput = 200 + volume_size = 50 + tags = { + Name = "my-root-block" + } + }, + ] + + ebs_block_device = [ + { + device_name = "/dev/sdf" + volume_type = "gp3" + volume_size = 5 + throughput = 200 + encrypted = true + kms_key_id = aws_kms_key.this.arn + tags = { + MountPoint = "/mnt/data" + } + } + ] + + tags = merge( + local.tags, + { + Name = "${local.name}-cpu-options" + } + ) +} + ################################################################################ # Supporting Resources ################################################################################ @@ -362,6 +431,16 @@ data "aws_ami" "amazon_linux" { } } +data "aws_ami" "amazon_linux_23" { + most_recent = true + owners = ["amazon"] + + filter { + name = "name" + values = ["al2023-ami-2023*-x86_64"] + } +} + module "security_group" { source = "terraform-aws-modules/security-group/aws" version = "~> 4.0" diff --git a/main.tf b/main.tf index 46b23b46..8d304690 100644 --- a/main.tf +++ b/main.tf @@ -46,6 +46,16 @@ resource "aws_instance" "this" { ebs_optimized = var.ebs_optimized + dynamic "cpu_options" { + for_each = length(var.cpu_options) > 0 ? [var.cpu_options] : [] + + content { + core_count = try(cpu_options.value.core_count, null) + threads_per_core = try(cpu_options.value.threads_per_core, null) + amd_sev_snp = try(cpu_options.value.amd_sev_snp, null) + } + } + dynamic "capacity_reservation_specification" { for_each = length(var.capacity_reservation_specification) > 0 ? [var.capacity_reservation_specification] : [] diff --git a/variables.tf b/variables.tf index b1b92dbf..2951625e 100644 --- a/variables.tf +++ b/variables.tf @@ -260,6 +260,12 @@ variable "timeouts" { default = {} } +variable "cpu_options" { + description = "Defines CPU options to apply to the instance at launch time." + type = any + default = {} +} + variable "cpu_core_count" { description = "Sets the number of CPU cores for an instance" # This option is only supported on creation of instance type that support CPU Options https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-optimize-cpu.html#cpu-options-supported-instances-values type = number diff --git a/versions.tf b/versions.tf index eddf9d5b..fd4d1167 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 4.20" + version = ">= 4.66" } } } From 5e9901a78a21bb01af8a32d16290fd75d9ebad41 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Sat, 6 May 2023 15:01:41 +0200 Subject: [PATCH 2/8] run of pre-commit hooks --- examples/complete/versions.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index eddf9d5b..fd4d1167 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 4.20" + version = ">= 4.66" } } } From 3d9dc2d7767dca035aff327084ee8fe3637aad5f Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Sat, 6 May 2023 15:03:14 +0200 Subject: [PATCH 3/8] run of pre-commit hooks --- README.md | 5 +++-- examples/complete/README.md | 6 ++++-- examples/complete/main.tf | 8 ++++---- variables.tf | 12 ------------ wrappers/main.tf | 1 + 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 33d8151c..62540a88 100644 --- a/README.md +++ b/README.md @@ -162,13 +162,13 @@ The following combinations are supported to conditionally create resources: | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 4.20 | +| [aws](#requirement\_aws) | >= 4.66 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 4.20 | +| [aws](#provider\_aws) | >= 4.66 | ## Modules @@ -199,6 +199,7 @@ No modules. | [capacity\_reservation\_specification](#input\_capacity\_reservation\_specification) | Describes an instance's Capacity Reservation targeting option | `any` | `{}` | no | | [cpu\_core\_count](#input\_cpu\_core\_count) | Sets the number of CPU cores for an instance | `number` | `null` | no | | [cpu\_credits](#input\_cpu\_credits) | The credit option for CPU usage (unlimited or standard) | `string` | `null` | no | +| [cpu\_options](#input\_cpu\_options) | Defines CPU options to apply to the instance at launch time. | `any` | `{}` | no | | [cpu\_threads\_per\_core](#input\_cpu\_threads\_per\_core) | Sets the number of CPU threads per core for an instance (has no effect unless cpu\_core\_count is also set) | `number` | `null` | no | | [create](#input\_create) | Whether to create an instance | `bool` | `true` | no | | [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` | `false` | no | diff --git a/examples/complete/README.md b/examples/complete/README.md index 63accd79..18d25d8e 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -20,19 +20,20 @@ Note that this example may create resources which can cost money. Run `terraform | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 4.20 | +| [aws](#requirement\_aws) | >= 4.66 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 4.20 | +| [aws](#provider\_aws) | >= 4.66 | ## Modules | Name | Source | Version | |------|--------|---------| | [ec2\_complete](#module\_ec2\_complete) | ../../ | n/a | +| [ec2\_cpu\_options](#module\_ec2\_cpu\_options) | ../../ | n/a | | [ec2\_disabled](#module\_ec2\_disabled) | ../../ | n/a | | [ec2\_metadata\_options](#module\_ec2\_metadata\_options) | ../../ | n/a | | [ec2\_multiple](#module\_ec2\_multiple) | ../../ | n/a | @@ -55,6 +56,7 @@ Note that this example may create resources which can cost money. Run `terraform | [aws_network_interface.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_interface) | resource | | [aws_placement_group.web](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/placement_group) | resource | | [aws_ami.amazon_linux](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | +| [aws_ami.amazon_linux_23](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | | [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source | ## Inputs diff --git a/examples/complete/main.tf b/examples/complete/main.tf index bc446e5a..0cdd484f 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -55,7 +55,7 @@ module "ec2_complete" { user_data_replace_on_change = true cpu_options = { - core_count = 2 + core_count = 2 threads_per_core = 1 } enable_volume_tags = false @@ -246,7 +246,7 @@ module "ec2_spot_instance" { user_data_base64 = base64encode(local.user_data) cpu_options = { - core_count = 2 + core_count = 2 threads_per_core = 1 } @@ -364,9 +364,9 @@ module "ec2_cpu_options" { user_data_replace_on_change = true cpu_options = { - core_count = 2 + core_count = 2 threads_per_core = 1 - amd_sev_snp = "enabled" + amd_sev_snp = "enabled" } enable_volume_tags = false root_block_device = [ diff --git a/variables.tf b/variables.tf index 2951625e..68edfc26 100644 --- a/variables.tf +++ b/variables.tf @@ -266,18 +266,6 @@ variable "cpu_options" { default = {} } -variable "cpu_core_count" { - description = "Sets the number of CPU cores for an instance" # This option is only supported on creation of instance type that support CPU Options https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-optimize-cpu.html#cpu-options-supported-instances-values - type = number - default = null -} - -variable "cpu_threads_per_core" { - description = "Sets the number of CPU threads per core for an instance (has no effect unless cpu_core_count is also set)" - type = number - default = null -} - # Spot instance request variable "create_spot_instance" { description = "Depicts if the instance is a spot instance" diff --git a/wrappers/main.tf b/wrappers/main.tf index 12a4b59a..e8d0f591 100644 --- a/wrappers/main.tf +++ b/wrappers/main.tf @@ -50,6 +50,7 @@ module "wrapper" { enable_volume_tags = try(each.value.enable_volume_tags, var.defaults.enable_volume_tags, true) vpc_security_group_ids = try(each.value.vpc_security_group_ids, var.defaults.vpc_security_group_ids, null) timeouts = try(each.value.timeouts, var.defaults.timeouts, {}) + cpu_options = try(each.value.cpu_options, var.defaults.cpu_options, {}) cpu_core_count = try(each.value.cpu_core_count, var.defaults.cpu_core_count, null) cpu_threads_per_core = try(each.value.cpu_threads_per_core, var.defaults.cpu_threads_per_core, null) create_spot_instance = try(each.value.create_spot_instance, var.defaults.create_spot_instance, false) From 0f8344ebef2c69f322f89395023eb433e75de177 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Sat, 6 May 2023 15:05:41 +0200 Subject: [PATCH 4/8] run of pre-commit hooks --- README.md | 2 -- main.tf | 26 ++++++++++++++++++++------ wrappers/main.tf | 2 -- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 62540a88..f1702ef3 100644 --- a/README.md +++ b/README.md @@ -197,10 +197,8 @@ No modules. | [associate\_public\_ip\_address](#input\_associate\_public\_ip\_address) | Whether to associate a public IP address with an instance in a VPC | `bool` | `null` | no | | [availability\_zone](#input\_availability\_zone) | AZ to start the instance in | `string` | `null` | no | | [capacity\_reservation\_specification](#input\_capacity\_reservation\_specification) | Describes an instance's Capacity Reservation targeting option | `any` | `{}` | no | -| [cpu\_core\_count](#input\_cpu\_core\_count) | Sets the number of CPU cores for an instance | `number` | `null` | no | | [cpu\_credits](#input\_cpu\_credits) | The credit option for CPU usage (unlimited or standard) | `string` | `null` | no | | [cpu\_options](#input\_cpu\_options) | Defines CPU options to apply to the instance at launch time. | `any` | `{}` | no | -| [cpu\_threads\_per\_core](#input\_cpu\_threads\_per\_core) | Sets the number of CPU threads per core for an instance (has no effect unless cpu\_core\_count is also set) | `number` | `null` | no | | [create](#input\_create) | Whether to create an instance | `bool` | `true` | no | | [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` | `false` | no | | [create\_spot\_instance](#input\_create\_spot\_instance) | Depicts if the instance is a spot instance | `bool` | `false` | no | diff --git a/main.tf b/main.tf index 8d304690..ca7d524c 100644 --- a/main.tf +++ b/main.tf @@ -21,8 +21,6 @@ resource "aws_instance" "this" { ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) instance_type = var.instance_type - cpu_core_count = var.cpu_core_count - cpu_threads_per_core = var.cpu_threads_per_core hibernation = var.hibernation user_data = var.user_data @@ -189,8 +187,6 @@ resource "aws_instance" "ignore_ami" { ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) instance_type = var.instance_type - cpu_core_count = var.cpu_core_count - cpu_threads_per_core = var.cpu_threads_per_core hibernation = var.hibernation user_data = var.user_data @@ -214,6 +210,16 @@ resource "aws_instance" "ignore_ami" { ebs_optimized = var.ebs_optimized + dynamic "cpu_options" { + for_each = length(var.cpu_options) > 0 ? [var.cpu_options] : [] + + content { + core_count = try(cpu_options.value.core_count, null) + threads_per_core = try(cpu_options.value.threads_per_core, null) + amd_sev_snp = try(cpu_options.value.amd_sev_snp, null) + } + } + dynamic "capacity_reservation_specification" { for_each = length(var.capacity_reservation_specification) > 0 ? [var.capacity_reservation_specification] : [] @@ -353,8 +359,6 @@ resource "aws_spot_instance_request" "this" { ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) instance_type = var.instance_type - cpu_core_count = var.cpu_core_count - cpu_threads_per_core = var.cpu_threads_per_core hibernation = var.hibernation user_data = var.user_data @@ -389,6 +393,16 @@ resource "aws_spot_instance_request" "this" { valid_from = var.spot_valid_from # End spot request specific attributes + dynamic "cpu_options" { + for_each = length(var.cpu_options) > 0 ? [var.cpu_options] : [] + + content { + core_count = try(cpu_options.value.core_count, null) + threads_per_core = try(cpu_options.value.threads_per_core, null) + amd_sev_snp = try(cpu_options.value.amd_sev_snp, null) + } + } + dynamic "capacity_reservation_specification" { for_each = length(var.capacity_reservation_specification) > 0 ? [var.capacity_reservation_specification] : [] diff --git a/wrappers/main.tf b/wrappers/main.tf index e8d0f591..7bbd4167 100644 --- a/wrappers/main.tf +++ b/wrappers/main.tf @@ -51,8 +51,6 @@ module "wrapper" { vpc_security_group_ids = try(each.value.vpc_security_group_ids, var.defaults.vpc_security_group_ids, null) timeouts = try(each.value.timeouts, var.defaults.timeouts, {}) cpu_options = try(each.value.cpu_options, var.defaults.cpu_options, {}) - cpu_core_count = try(each.value.cpu_core_count, var.defaults.cpu_core_count, null) - cpu_threads_per_core = try(each.value.cpu_threads_per_core, var.defaults.cpu_threads_per_core, null) create_spot_instance = try(each.value.create_spot_instance, var.defaults.create_spot_instance, false) spot_price = try(each.value.spot_price, var.defaults.spot_price, null) spot_wait_for_fulfillment = try(each.value.spot_wait_for_fulfillment, var.defaults.spot_wait_for_fulfillment, null) From f0682df78ec46e00b1b329b6fd822bb03308223e Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Sat, 6 May 2023 15:06:13 +0200 Subject: [PATCH 5/8] run of pre-commit hooks --- main.tf | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.tf b/main.tf index ca7d524c..60e3184f 100644 --- a/main.tf +++ b/main.tf @@ -19,9 +19,9 @@ data "aws_ssm_parameter" "this" { resource "aws_instance" "this" { count = local.create && !var.ignore_ami_changes && !var.create_spot_instance ? 1 : 0 - ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) - instance_type = var.instance_type - hibernation = var.hibernation + ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) + instance_type = var.instance_type + hibernation = var.hibernation user_data = var.user_data user_data_base64 = var.user_data_base64 @@ -185,9 +185,9 @@ resource "aws_instance" "this" { resource "aws_instance" "ignore_ami" { count = local.create && var.ignore_ami_changes && !var.create_spot_instance ? 1 : 0 - ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) - instance_type = var.instance_type - hibernation = var.hibernation + ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) + instance_type = var.instance_type + hibernation = var.hibernation user_data = var.user_data user_data_base64 = var.user_data_base64 @@ -357,9 +357,9 @@ resource "aws_instance" "ignore_ami" { resource "aws_spot_instance_request" "this" { count = local.create && var.create_spot_instance ? 1 : 0 - ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) - instance_type = var.instance_type - hibernation = var.hibernation + ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) + instance_type = var.instance_type + hibernation = var.hibernation user_data = var.user_data user_data_base64 = var.user_data_base64 From 65a5143df0b53880f151eeeff418ec571aa8c096 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Wed, 17 May 2023 17:20:08 +0200 Subject: [PATCH 6/8] revert back of cpu_threads_per_core and cpu_count for backwards compatibility --- README.md | 2 ++ main.tf | 8 +++++--- variables.tf | 12 ++++++++++++ wrappers/main.tf | 2 ++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f1702ef3..62540a88 100644 --- a/README.md +++ b/README.md @@ -197,8 +197,10 @@ No modules. | [associate\_public\_ip\_address](#input\_associate\_public\_ip\_address) | Whether to associate a public IP address with an instance in a VPC | `bool` | `null` | no | | [availability\_zone](#input\_availability\_zone) | AZ to start the instance in | `string` | `null` | no | | [capacity\_reservation\_specification](#input\_capacity\_reservation\_specification) | Describes an instance's Capacity Reservation targeting option | `any` | `{}` | no | +| [cpu\_core\_count](#input\_cpu\_core\_count) | Sets the number of CPU cores for an instance | `number` | `null` | no | | [cpu\_credits](#input\_cpu\_credits) | The credit option for CPU usage (unlimited or standard) | `string` | `null` | no | | [cpu\_options](#input\_cpu\_options) | Defines CPU options to apply to the instance at launch time. | `any` | `{}` | no | +| [cpu\_threads\_per\_core](#input\_cpu\_threads\_per\_core) | Sets the number of CPU threads per core for an instance (has no effect unless cpu\_core\_count is also set) | `number` | `null` | no | | [create](#input\_create) | Whether to create an instance | `bool` | `true` | no | | [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` | `false` | no | | [create\_spot\_instance](#input\_create\_spot\_instance) | Depicts if the instance is a spot instance | `bool` | `false` | no | diff --git a/main.tf b/main.tf index 60e3184f..feef5419 100644 --- a/main.tf +++ b/main.tf @@ -19,9 +19,11 @@ data "aws_ssm_parameter" "this" { resource "aws_instance" "this" { count = local.create && !var.ignore_ami_changes && !var.create_spot_instance ? 1 : 0 - ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) - instance_type = var.instance_type - hibernation = var.hibernation + ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) + instance_type = var.instance_type + cpu_core_count = var.cpu_core_count + cpu_threads_per_core = var.cpu_threads_per_core + hibernation = var.hibernation user_data = var.user_data user_data_base64 = var.user_data_base64 diff --git a/variables.tf b/variables.tf index 68edfc26..2951625e 100644 --- a/variables.tf +++ b/variables.tf @@ -266,6 +266,18 @@ variable "cpu_options" { default = {} } +variable "cpu_core_count" { + description = "Sets the number of CPU cores for an instance" # This option is only supported on creation of instance type that support CPU Options https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-optimize-cpu.html#cpu-options-supported-instances-values + type = number + default = null +} + +variable "cpu_threads_per_core" { + description = "Sets the number of CPU threads per core for an instance (has no effect unless cpu_core_count is also set)" + type = number + default = null +} + # Spot instance request variable "create_spot_instance" { description = "Depicts if the instance is a spot instance" diff --git a/wrappers/main.tf b/wrappers/main.tf index 7bbd4167..e8d0f591 100644 --- a/wrappers/main.tf +++ b/wrappers/main.tf @@ -51,6 +51,8 @@ module "wrapper" { vpc_security_group_ids = try(each.value.vpc_security_group_ids, var.defaults.vpc_security_group_ids, null) timeouts = try(each.value.timeouts, var.defaults.timeouts, {}) cpu_options = try(each.value.cpu_options, var.defaults.cpu_options, {}) + cpu_core_count = try(each.value.cpu_core_count, var.defaults.cpu_core_count, null) + cpu_threads_per_core = try(each.value.cpu_threads_per_core, var.defaults.cpu_threads_per_core, null) create_spot_instance = try(each.value.create_spot_instance, var.defaults.create_spot_instance, false) spot_price = try(each.value.spot_price, var.defaults.spot_price, null) spot_wait_for_fulfillment = try(each.value.spot_wait_for_fulfillment, var.defaults.spot_wait_for_fulfillment, null) From c3a3c269032073b45dcfacec51ad94ab4cc3dfbd Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Wed, 31 May 2023 00:34:51 +0200 Subject: [PATCH 7/8] revert back of cpu_threads_per_core and cpu_count for backwards compatibility --- main.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.tf b/main.tf index feef5419..1dd92ff6 100644 --- a/main.tf +++ b/main.tf @@ -189,6 +189,8 @@ resource "aws_instance" "ignore_ami" { ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) instance_type = var.instance_type + cpu_core_count = var.cpu_core_count + cpu_threads_per_core = var.cpu_threads_per_core hibernation = var.hibernation user_data = var.user_data @@ -361,6 +363,8 @@ resource "aws_spot_instance_request" "this" { ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) instance_type = var.instance_type + cpu_core_count = var.cpu_core_count + cpu_threads_per_core = var.cpu_threads_per_core hibernation = var.hibernation user_data = var.user_data From aad6f05b4e0040f613b5418df21c9e96d3e73c08 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Wed, 31 May 2023 00:36:03 +0200 Subject: [PATCH 8/8] revert back of cpu_threads_per_core and cpu_count for backwards compatibility --- main.tf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.tf b/main.tf index 1dd92ff6..90669c21 100644 --- a/main.tf +++ b/main.tf @@ -187,11 +187,11 @@ resource "aws_instance" "this" { resource "aws_instance" "ignore_ami" { count = local.create && var.ignore_ami_changes && !var.create_spot_instance ? 1 : 0 - ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) - instance_type = var.instance_type + ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) + instance_type = var.instance_type cpu_core_count = var.cpu_core_count cpu_threads_per_core = var.cpu_threads_per_core - hibernation = var.hibernation + hibernation = var.hibernation user_data = var.user_data user_data_base64 = var.user_data_base64 @@ -361,11 +361,11 @@ resource "aws_instance" "ignore_ami" { resource "aws_spot_instance_request" "this" { count = local.create && var.create_spot_instance ? 1 : 0 - ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) - instance_type = var.instance_type + ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) + instance_type = var.instance_type cpu_core_count = var.cpu_core_count cpu_threads_per_core = var.cpu_threads_per_core - hibernation = var.hibernation + hibernation = var.hibernation user_data = var.user_data user_data_base64 = var.user_data_base64