I’m learning Terraform course ‘Learn DevOps: Infrastructure Automation With Terraform’ from Udemy. As per the exercise 'First steps in terraform - Spinning up an instance’when i’m running ‘instance.tf’ i’m getting the below error.
This is an AWS error rather than a Terraform error, so you might get a more specific answer if you ask in an AWS forum, but I’ll do my best to guess what might be going on here. I’m also not familiar with the Udemy course you are following, so I’m not sure if there’s any additional context in that guide about how this is set up.
One guess is that the AMI you’ve selected here is using one or more EC2 features that are not available on a t2.micro instance, in which case you’d need to select a more specialized instance type that has those features available.
Another guess is that t2.micro instances are currently not available in your target availability zone. That doesn’t seem very likely to me given how common the t2.micro instance type is, but I believe that is one reason why EC2 can return this error message.
Sadly it’s impossible to be sure what’s going on here because that error message is very generic and its details are part of the underlying AWS API implementation rather than something Terraform directly controls. I hope the above hints will help! If not, you might be able to get some AWS-specific help from the AWS developer forums or by contacting your course instructor to verify that this AMI ID is still valid.
Issue resolved. I changed the region to US West and changed the ami id accordingly. It worked. The problem was with the region and ami id. ThankU for taking time to read my post and reply.
I am having exact problem as reported in this thread. I have tried to change the region but the error is persisting. On running ‘terraform apply’ in debug mode, I could see below error-
For me it was happening because i was using obseleted instance type m3 family is discard and i was refering this into my template i changed it to m4 it starts working
So if you are using any resource that doesn’t exist on aws you will see the above error
I’m also facing same issue, I’ve changed the instance type from T2.micro to T3.micro and changed the AMI ID (In ami it comes with two architecture arm and X86). I hope by default it will create using arm . So I’ve selected ami only have x86 then instance will create successfully . try it.
I also have the same issue and then i change the ami . The ami you provided must be single mean to say that the instance you want to launch have only one ami id then it will work fine.
I’m having the same issue. The funny thing is that if i run the ami and t2.micro manually, it works just fine. If i’m trying by terraform, it outputs that error. Now i’ll try to play with instance types and also change the region. I’ll post here how it works.
Thanks
Initially I was working on Frankfurt region. (eu-central-1) and it didn’t work with t2.micro.
As soon as i switched to t3.micro it started working. Thanks for the hint.
I noticed that if i increase the number of instances and apply the changes it’s modifying very very slowly, like 7 mins for one or two instances. i destroyed all and apply terraform again already with t3.micro, the same, it modified everything but take about 7 mins and outputs also some error.
It change the instance type from t2.medium back to t2.micro but unable to start the instance.
Ideally terraform should not perform the update in-place action since t2.medium to t2.micro is ebs-optimized and terraform should destroy and recreate the instance. something missing at terraform side,
My issue was, the selected instance types did not match the EBS optimization.
This AWS provided error message is meaningless and unhelpful.
When you have many different parameters coming from many different remote states the only way to find out what went wrong if you extract the resource from the TF plan and read it in its own.