terraform-aws-ec2-instance
terraform-aws-ec2-instance copied to clipboard
'An argument named "XXX" is not expected here' during terraform plan
Description
We upgraded the module version to the latest (5.8.0), the terraform version to the latest (v1.12.0) and deleted the local
.terraform
When doing a terraform plan, we have a bunch of errors looking like :
β Error: Unsupported argument
β
β on .terraform\modules\ec2_bastion_deploy_onprem.ec2_instance\main.tf line 183, in resource "aws_instance" "ignore_ami":
β 183: cpu_threads_per_core = var.cpu_threads_per_core
β
β An argument named "cpu_threads_per_core" is not expected here.
This seems to be linked to the recent (15h ago) of at least :
-
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/spot_instance_request
-
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance
-
[X] β I have searched the open/closed issues and my issue is not listed.
Versions
-
Module version [Required]: 5.8.0 (tested with 5.0.0 as well)
-
Terraform version: Terraform v1.12.2 on windows_amd64
-
Provider version(s):
- provider registry.terraform.io/hashicorp/archive v2.7.1
- provider registry.terraform.io/hashicorp/aws v6.0.0
- provider registry.terraform.io/hashicorp/null v3.2.4
- provider registry.terraform.io/hashicorp/random v3.7.2
- provider registry.terraform.io/hashicorp/tls v4.1.0
Reproduction Code [Required]
Simply use the module. In our context, the code is :
module "ec2_instance" {
source = "terraform-aws-modules/ec2-instance/aws"
version = "5.8.0"
name = local.instance_name
ami = var.ami_id != null ? var.ami_id : data.aws_ami.amazon_linux[0].id
instance_type = var.instance_class
key_name = aws_key_pair.ssh_key.key_name
associate_public_ip_address = true
vpc_security_group_ids = var.vpc_security_group_ids
subnet_id = var.subnet_id
monitoring = var.env_short_name == "prd" ? true : false
user_data = var.user_data
user_data_replace_on_change = false
# Creation of dedicated instance profile and IAM role
create_iam_instance_profile = var.iam_role_name_to_create != null ? true : false
iam_role_name = var.iam_role_name_to_create
iam_role_policies = var.custom_policies_map
iam_role_use_name_prefix = false
root_block_device = [{
# t2.2xlarge has a 50GB root volume, t2.micro has 8GB in default configuration, it's not enouth for our needs
volume_size = var.volume_size
volume_type = "gp2"
}]
tags = merge(var.tags, {
Name = local.instance_name
})
volume_tags = merge(var.tags, {
Name = replace(local.instance_name, "-ec2-", "-ebs-")
})
}
Steps to reproduce the behavior:
- running
terraform planeither in local or in ci
Expected behavior
Up-to-date variables are in the latest module or the submodules have fixed version (best solution IMHO to avoid such breaking changes)
Actual behavior
Plan fails.
Terminal Output Screenshot(s)
Additional context
Same problem. It's because of the new version of Hashicorp AWS provider (v6.0.0) that was released, in which:
resource/aws_instance: Remove cpu_core_count and cpu_threads_per_core. Instead, use cpu_options
I temporarily fixed this by limiting the version:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.100.0" # ">= 5.100.0, < 6.0.0"
}
}
}
https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/pulls
Same issue as with autoscaling groups?
Same issue, but I need the aws 6.0.0 as it otherwise blocks an issue with the vpc module. Otherwise I would have attempted the temp fix suggested earlier
Wouldn't it make more sense to make a v5.8.1 release that caps the provider version? Seems like an easy solution...
I applied a temporary fix in my code by using terraform provider version 5.26.0 and using 2.19.0 version of the "terraform-aws-modules/ec2-instance/aws" module.
https://github.com/hashicorp/terraform-provider-aws/issues/42280
same error here.
This issue has been resolved in version 6.0.0 :tada:
I'm going to lock this issue because it has been closed for 30 days β³. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.