Search code examples
amazon-web-servicesamazon-ec2terraformterraform-provider-aws

Terraform AWS EC2 instance - Ubuntu error


I'm trying to launch an EC2 instance within Terraform. I'm following a 2 years ago tutorial and I get an error when trying to run terraform apply: "creating EC2 Instance: InvalidParameterValue: The architecture 'i386,x86_64' of the specified instance type does not match the architecture 'arm64' of the specified AMI. Specify an instance type and an AMI that have matching architectures, and try again. You can use 'describe-instance-types' or 'describe-images' to discover the architecture of the instance type or AMI." My code:

provider "aws" {
  region = "us-east-1"
  access_key = "...//key"
  secret_key = "...//key"
}

resource "aws_instance" "my-first-server" {
  ami           = "ami-007855ac798b5175e"
  instance_type = "t2.micro"
}

I'm really new to Cloud/terraform and I have no idea what is the issue. I copied from AWS the provided AMI for 64-bit (x86).


Solution

  • There is absolutely nothing wrong with your code. I just deployed your code in us-east-1 and everything works exactly as expected. Thus your issue is likely to be caused by other factors, e.g. other code version which you use, which is not provided in the question.