hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.61k stars 9k forks source link

Instance market options are not supported with the launch template #18025

Open surajnarwade opened 3 years ago

surajnarwade commented 3 years ago

I am trying out the EKS node group along with the launch template to spin spot instance & I am getting the following error:

Error: error creating EKS Node Group (eks-demo:eks-demo-spot-workers-demo): InvalidParameterException: Instance market options are not supported with the launch template.
{
  RespMetadata: {
    StatusCode: 400,
    RequestID: "df13de8b-d288-47f2-85fa-414943bf3890"
  },
  Message_: "Instance market options are not supported with the launch template."
}

Configuration I am passing to launch template:


  instance_market_options {
    market_type = "spot" 
    spot_options {
    max_price = "0.1"
   }
  }
kayahk commented 3 years ago

I am seeing this error, too when trying to pass (or rather add) this to the template:

instance_market_options {
    market_type = "spot"
    spot_options {
      spot_instance_type = "persistent"
    }
  }
ssala7 commented 2 years ago

Any updates on this?

Gabz7 commented 1 year ago

Good day, is there any news on this issue?

mattburgess commented 1 year ago

This is an issue with the underlying EKS service. Unfortunately, the user-facing documentation doesn't make this clear. The only reference to this that I could find is: https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/eks@v1.27.0/types#LaunchTemplateSpecification:

An object representing a node group launch template specification. The launch template can't include...RequestSpotInstances (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RequestSpotInstances.html).

Whilst you're prohibited from putting put fine-grained market options in a launch template used by EKS, you can specify the use of Spot instances using capacity_type = "SPOT" on your aws_eks_node_group resource.

MarceloFCandido commented 1 year ago

I am facing this issue. Although is possible to use capacity_type = "SPOT" for creating requests with spots, as @mattburgess said, I also need to create those spots in a persistent mode. Seems that the default mode is one-time and the only way to change that is by using instance_market_options block. Is there any another way that I'm missing or any workaround for it?

Also, seems that the API used by the provider (specifically by aws_launch_template) is RequestSpotInstances and that fact is the one causing trouble. Is it possible to change it for CreateFleet and/or CreateAutoScalingGroup APIs as suggested by AWS?