Hello,
I ran into this a couple of times today while trying out the t3.micro instances. Even if I didn't change anything or I changed an unrelated resource (e.g the security group name) it would still update the credit specification.
Terraform v0.11.8
provider "aws" {
region = "eu-west-1"
}
resource "aws_instance" "example" {
ami = "ami-0bdb1d6c15a40392c"
instance_type = "t3.micro"
vpc_security_group_ids = ["${aws_security_group.allow_all.id}"]
key_name = "jons-ubuntu"
user_data = <<-EOF
#!/bin/bash
yum -y install httpd
systemctl start httpd.service
systemctl enable httpd
echo "Hello, World" > /var/www/html/index.html
EOF
tags {
Name = "terraform-example"
}
}
resource "aws_security_group" "allow_all" {
name = "allow_everything"
description = "Allow all traffic"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
https://gist.github.com/Jonathan-7/6c33ec9315158eeb1e4278132e2ced1d
Don't update anything.
Changed credit specification:
Terraform will perform the following actions:
~ aws_instance.example
credit_specification.0.cpu_credits: "unlimited" => "standard"
run terraform apply twice
terraform applyterraform applyAccording to the T3 instance product documentation:
T3 instances start in Unlimited mode by default
I believe we default the cpu_credits attribute to standard since that matched the previous behavior with T2 instances.
If you would like to continue to not configure the instance credit_specification (leaving the default), you should be able to workaround this issue with the below until a proper code fix is released:
resource "aws_instance" "example" {
# ... other configuration ...
lifecycle {
ignore_changes = ["credit_specification.0.cpu_credits"]
}
}
This issue seems related to mine:
* aws_instance.jenkins: aws_instance.jenkins: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.
Please include the following information in your report:
Terraform Version: 0.11.8
Resource ID: aws_instance.jenkins
Mismatch reason: attribute mismatch: credit_specification.0.cpu_credits
Diff One:
credit_specification.0.cpu_credits":*terraform.ResourceAttrDiff{Old:"unlimited", New:"standard", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}
Diff Two:
lacks credit_specification
I can provide the full diff on request but I'll have to clean it up.
This occurs when changing the user_data on an aws_instance with instance_type = t3.medium
resource:
resource "aws_instance" "jenkins" {
ami = "ami-09261ff1cf8893662"
instance_type = "t2.medium"
subnet_id = "subnet-64f47202"
security_groups = ["${aws_security_group.instance.id}"]
user_data = "${file("${path.module}/user_data.sh")}"
}
Tried the ignore_changes workaround and are still seeing the diffs didn't match during apply error. So workaround doesn't work in all cases? Going back to t2s in the interim.
I've encountered this with t3.* instances too. My version is Terraform v0.11.1 + provider.aws v1.28.0.
@Jonathan-7 As my workaround I've decided to lock the cpu_credits:
resource "aws_instance" "example" {
# ...
credit_specification = {
cpu_credits = "unlimited"
}
}
So this is quite similar to ignore_changes solution, or am I wrong here?
@kmotrebski your workaround should be fine. I expect them to have the credits as unlimited by default in an upcoming release.
@bflad I will work on this issue.
not sure if its relevant but I set
credit_specification = {
cpu_credits = "standard"
}
explicitly in code.... but Terraform still builds t3 instances with t.unlimited enabled. Only a second apply then corrects the credit specification
probably related and would be nice to have fixed
The fix for this has been merged into master for the aws_instance resource and will release with version 1.37.0 of the AWS provider, likely tomorrow.
This has been released in version 1.37.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!