Team,
I’m currently learning and doing hands-on for terraform on AWS. I’m able to create the “linux” t2.micro EC2, but when I tried to change the AMI and the instance type of the “MAC”, it is throwing the below error -
I have tried in us-east-1 and also in us-east-2 regions
│ Error: creating EC2 Instance: Unsupported: The requested tenancy is not supported for this instance type. Please check the documentation for supported configurations.
│ status code: 400, request id: 106f2f25-20a7-44b7-9934-7de834b23684
│
│ with aws_instance.my_ec2,
│ on main.tf line 14, in resource "aws_instance" "my_ec2":
│ 14: resource "aws_instance" "my_ec2" {
Below is my config file -
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~>5.0"
}
}
}
provider "aws" {
region = "us-east-2"
}
resource "aws_instance" "my_ec2" {
ami = "ami-06e4de7ffd25750b8"
instance_type = "mac1.metal"
tags = {
"Name" = "Hello World"
}
}
Hi @pavankumarmolleti,
I’ve never used the “mac” instance types in EC2 so I am making some guesses here but maybe these guesses will give you some clues.
The error message talks about “the requested tenancy”. In EC2, the concept of “tenancy” refers to what kind of capacity you are reserving:
- “default” tenancy typically means that you are requesting a virtual machine that runs alongside other EC2 instances on the same physical server
- “dedicated” tenancy means that you are requesting full control of some hardware that cannot support shared allocation as virtual machines
- “host” tenancy is, I think, somewhere between these two… maybe that you are requesting a virtual machine but you don’t want to have other customers’ VMs sharing the same server (I’m not sure about this one)
Since your configuration doesn’t mention tenancy at all, I assume EC2 is assuming you mean to select “default”.
My guess here is that the “mac” instance types don’t support default tenancy because macOS isn’t designed to support multiple macOS VMs running on the same host. Perhaps when you request a “mac” instance you are reserving full control over a single-tenant Apple computer in one of Amazon’s data centers, and so you might need to specify “dedicated” tenancy.
The aws_instance
resource type supports an optional argument tenancy
for changing the tenancy setting:
tenancy = "dedicated"
Perhaps you could try adding that setting to see if that allows the instance to be created. Note that dedicated tenancy is typically considerably more expensive than default tenancy, so please make sure to review the relevant pricing guide before you use this to avoid unexpected costs.
If my guess above is not correct then hopefully someone else with more experience with these features can make a more confident suggestion.