clong / DetectionLab

Automate the creation of a lab environment complete with security tooling and logging best practices
MIT License
4.64k stars 987 forks source link

Terraform: Unsupported: Your requested instance type (t2.medium Windows) is not supported in your requested Availability Zone #424

Closed clong closed 4 years ago

clong commented 4 years ago
Error: Error launching source instance: Unsupported: Your requested instance type (t2.medium) is not supported in your requested Availability Zone (us-west-1a). Please retry your request by not specifying an Availability Zone or choosing us-west-1b, us-west-1c.
    status code: 400, request id: 66839b2b-3ef6-41ba-a3c2-452c80ee1732

  on main.tf line 157, in resource "aws_instance" "logger":
 157: resource "aws_instance" "logger" {

Error: Error launching source instance: Unsupported: Your requested instance type (t2.medium Windows) is not supported in your requested Availability Zone (us-west-1a). Please retry your request by not specifying an Availability Zone or choosing us-west-1b, us-west-1c.
    status code: 400, request id: f226ea5d-49a3-4b67-8836-09d7f24a3617

  on main.tf line 204, in resource "aws_instance" "dc":
 204: resource "aws_instance" "dc" {

Error: Error launching source instance: Unsupported: Your requested instance type (t2.medium Windows) is not supported in your requested Availability Zone (us-west-1a). Please retry your request by not specifying an Availability Zone or choosing us-west-1b, us-west-1c.
    status code: 400, request id: 04172dad-68ae-48b8-8fe3-e136a764c7c4

  on main.tf line 238, in resource "aws_instance" "wef":
 238: resource "aws_instance" "wef" {

Error: Error launching source instance: Unsupported: Your requested instance type (t2.medium Windows) is not supported in your requested Availability Zone (us-west-1a). Please retry your request by not specifying an Availability Zone or choosing us-west-1b, us-west-1c.
    status code: 400, request id: 6239ab8e-eb5c-4110-85f7-973375635dd4

  on main.tf line 270, in resource "aws_instance" "win10":
 270: resource "aws_instance" "win10" {
clong commented 4 years ago

Temporary workaround is to set the default availability zone to us-west-1b in Line 11 of Terraform/variables.tf

clong commented 4 years ago

Looking for help on this one.

The Windows 2016 AMIs seem to support ENA natively (meaning I don't have to do anything for AWS to recognize them as supporting ENA):

DC

$ aws ec2 describe-images --image-id ami-00beb549af8618fd3 --query "Images[].EnaSupport"

[
    true
]

WEF

$ aws ec2 describe-images --image-id ami-09256c7aa0b81dc92 --query "Images[].EnaSupport"

[
    true
]

However, even after installing the Windows Enhanced Networking package on the Win10 Packer build, it isn't recognized as having ENA support after converting it to an AWS AMI:

WIN10 with ENA Package Pre-Installed from Packer via install-aws-ena.ps1

$ aws ec2 describe-images --image-id ami-004c16a4f87c540b8 --query "Images[].EnaSupport"

[
    false
]

Unfortunately, Terraform won't let us select a t3.medium instance for WIN10 unless it detects that ENA is enabled on the AMI:

Error: Error launching source instance: InvalidParameterCombination: Enhanced networking with the Elastic Network Adapter (ENA) is required for the 't3.medium' instance type. Ensure that you are using an AMI that is enabled for ENA.
clong commented 4 years ago

Ah, it looks like I have to create an instance, run aws ec2 modify-instance-attribute --instance-id instance_id --ena-support and then create a new AMI from that instance. Annoying, but I think it should probably work. Testing now.

clong commented 4 years ago

Doesn't seem to work yet. The WIN10 AMI doesn't pull any IP address after doing this and using a t3 instance.

clong commented 4 years ago

I don't think this solution is going to work from a build pipeline perspective. I either need to find a way to enable the support natively in the AMI without booting up an instance or just leave the Win10 host as a t2.

clong commented 4 years ago

Don't think it's worth fixing this by getting ENA supported on Win10, especially after us-west-1a stopped including t2 and t3 medium instances. I'm addressing this here: https://github.com/clong/DetectionLab/commit/d686a50f81a6709c82c4d9f097134cdc30898a27