2
votes

I have just getting started with terraform using aws services.

  1. I just created a new user IAM user and given it AdministrativeAccess
  2. Copied down the Access Key and Secret and pasted it in terraform instance.tf file under provider "aws" {}
  3. Ran the command: terraform init and it worked fine.
  4. Ran the command: terraform apply but in the end it gives me following error:

aws_instance.example: Creating...

Error: Error launching source instance: Unsupported: The requested configuration is currently not supported. Please check the documentation for supported configurations. status code: 400, request id: cf85fdcf-432e-23d3-1233-790cfb2aa33fs

on instance.tf line 7, in resource "aws_instance" "example": 7: resource "aws_instance" "example" {

Here is my terraform code:

provider "aws" {
  access_key = "ACCESS_KEY"
  secret_key = "SECRET_KEY"
  region     = "us-east-2"
}

resource "aws_instance" "example" {
  ami           = "ami-0b9bd0b532ebcf4c9"
  instance_type = "t2.micro"
}

Any help would be appreciatable,

Cheers :)

3
could you show your terraform code?c4f4t0r
I just updated my question with terraform code, also I just created AWS IAM user today, it could be problem on aws side but not sure. Thanks :)Syed Aqeel
I think that you missing some parameters like availability_zone, security groups and so on, better check the docsc4f4t0r

3 Answers

0
votes

The following worked for me after changing the eu-west-1 to eu-west-2 because for some reason eu-west-1 has no VPC (strangely, link). Second thing to change was ami.

Paste the following in instance.tf with correct ACCESS and SECRET keys and do terraform init and then terraform apply. It should work.

provider "aws" {
  access_key = "ACCESS_KEY"
  secret_key = "SECRET_KEY"
  region     = "eu-west-2"
}

resource "aws_instance" "example" {
  ami           = "ami-031e556ebe95c007e"
  instance_type = "t2.micro"
}
0
votes

For my case, I used the wrong AMI ID : I used the "64-bit Arm" arch instead of "64-bit x86".

Using the AMI ID of "64-bit x86" fixes the issue.

enter image description here

0
votes

The best options are to check your AMI and the region. This is not a terraform issue. Its AWS AMI or REGION problem.