terraform-aws-ec2-instance
terraform-aws-ec2-instance copied to clipboard
Setting cpu_credits for t4g instance does not set value though it's a burstable instance
Description
Instance type t4g supports burstable CPU credits mode, but if cpu_credits is set when using the ec2-instance module it doesn't get set on the created resource. Any created t4g instance will use the "unlimited" setting.
- [x] β I have searched the open/closed issues and my issue is not listed.
β οΈ Note
Before you submit an issue, please perform the following first:
- Remove the local
.terraformdirectory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/ - Re-initialize the project root to pull down modules:
terraform init - Re-attempt your terraform plan or apply and check if the issue still persists
Done
Versions
-
Module version [Required]: v4.1.4
-
Terraform version: Terraform v1.2.8 on linux_amd64
-
Provider version(s): provider registry.terraform.io/hashicorp/aws v4.29.0
Reproduction Code [Required]
data "aws_ssm_parameter" "ubuntu-jammy-arm64" {
name = "/aws/service/canonical/ubuntu/server/22.04/stable/current/arm64/hvm/ebs-gp2/ami-id"
}
module "ec2_instance" {
source = "terraform-aws-modules/ec2-instance/aws"
version = "4.1.4"
name = "t4g-credit-standard"
ami = data.aws_ssm_parameter.ubuntu-jammy-arm64.value
instance_type = "t4g.small"
monitoring = false
cpu_credits = "standard"
tags = {
Credit = "standard"
}
}
output "id" {
value = module.ec2_instance.id
}
Steps to reproduce the behavior:
- Create ec2_instance instance type t4g resource, set the cpu_credits to
standard(instance defaults tounlimitedif not specified) - Check
terraform planoutput to see nocredit_specificationis being sent - After
terraform applyverify with AWS the instance is usingunlimitedcredit specification usingaws ec2 describe-instance-credit-specifications --instance-ids
Expected behavior
credit_specification to be set as specified, or be left unset if not specified
Actual behavior
credit_specification is left unset in aws_instance resource, causing it to default to unlimited regardless of specified value
Terminal Output Screenshot(s)
β― terraform init >/dev/null && terraform plan 2>/dev/null | grep credit_specification
+ credit_specification {}
β― terraform apply
data.aws_ssm_parameter.ubuntu-jammy-arm64: Reading...
....
....
....
Outputs:
id = "i-0105c90890dd415f4"
β― aws ec2 describe-instance-credit-specifications --instance-ids i-0105c90890dd415f4
{
"InstanceCreditSpecifications": [
{
"InstanceId": "i-0105c90890dd415f4",
"CpuCredits": "unlimited"
}
]
}
Additional context
The local.is_t_instance_type function only includes the t2, t3, and t3a instance types, so won't automatically update with new instance types.