Following @jordanm advise I searched high and low for documentation and finally came across something similar at https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/spot_instance_request https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/spot-instances.md

and found this syntax in a related terraform configuration

spot_price = "1.10"

here is how it looks inside the EKS module:

module "eks" {
  source          = "terraform-aws-modules/eks/aws"
  cluster_name    = local.cluster_name
  cluster_version = var.kube_version
  subnets         = module.vpc.private_subnets
  vpc_id          = module.vpc.vpc_id
  enable_irsa     = true

  tags = {
    Environment = "training"
    GithubRepo  = "terraform-aws-eks"
    GithubOrg   = "terraform-aws-modules"
  }

  worker_groups = [
    
    {
      name                          = "worker-group-bot"
      instance_type                 = var.bot_instance
      disk_size                     = var.bot_disk_size
      additional_userdata           = "echo foo bar"
      additional_security_group_ids = [aws_security_group.worker_group_mgmt_two.id]
      asg_desired_capacity          = var.bot_desired
      asg_max_size                  = var.bot_max

      //      availability_zones = [var.availability_zone]
      //      subnets         = [module.vpc.private_subnets[0]]

      kubelet_extra_args      = "--node-labels=node.kubernetes.io/lifecycle=spot,prefer=bot"

      suspended_processes     = ["AZRebalance"]
      spot_price              = "1.10"

      tags = [
        {
          "key"                 = "k8s.io/cluster-autoscaler/enabled"
          "propagate_at_launch" = "false"
          "value"               = "true"
        },
        {
          "key"                 = "k8s.io/cluster-autoscaler/${local.cluster_name}"
          "propagate_at_launch" = "false"
          "value"               = "true"
        }
      ]
    },
  ]

  workers_additional_policies = ["arn:aws:iam::aws:policy/AutoScalingFullAccess"]
}


If someone knows where the documentation resides please comment.

Answer from Rubber Duck on Stack Overflow
🌐
Middleware Inventory
middlewareinventory.com › blog › terraform-eks-spot-instances
Creating EKS Cluster with SPOT instances - Terraform | Devops Junction
April 3, 2022 - How to create EKS Cluster with SPOT instances using Terraform. Terraform EKS SPOT instances example code. How to create EKS Cluster with SPOT instances and labels.
🌐
Stack Overflow
stackoverflow.com › questions › 61602324 › terraform-aws-eks-worker-node-spot-instance
amazon eks - Terraform aws eks worker node spot instance - Stack Overflow
You can set two pools, for example, one for on-demond (1 - x), one for spot instances (0 - 20), so it will always have at least one on-demond instance running. 2020-05-05T02:26:53.167Z+00:00 ... ,how do i set two pools , the Terraform docs just shows how to set up eithier spot inst or on demand , but not both , can you share skeleton code ..
Top answer
1 of 1
1

Following @jordanm advise I searched high and low for documentation and finally came across something similar at https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/spot_instance_request https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/spot-instances.md

and found this syntax in a related terraform configuration

spot_price = "1.10"

here is how it looks inside the EKS module:

module "eks" {
  source          = "terraform-aws-modules/eks/aws"
  cluster_name    = local.cluster_name
  cluster_version = var.kube_version
  subnets         = module.vpc.private_subnets
  vpc_id          = module.vpc.vpc_id
  enable_irsa     = true

  tags = {
    Environment = "training"
    GithubRepo  = "terraform-aws-eks"
    GithubOrg   = "terraform-aws-modules"
  }

  worker_groups = [
    
    {
      name                          = "worker-group-bot"
      instance_type                 = var.bot_instance
      disk_size                     = var.bot_disk_size
      additional_userdata           = "echo foo bar"
      additional_security_group_ids = [aws_security_group.worker_group_mgmt_two.id]
      asg_desired_capacity          = var.bot_desired
      asg_max_size                  = var.bot_max

      //      availability_zones = [var.availability_zone]
      //      subnets         = [module.vpc.private_subnets[0]]

      kubelet_extra_args      = "--node-labels=node.kubernetes.io/lifecycle=spot,prefer=bot"

      suspended_processes     = ["AZRebalance"]
      spot_price              = "1.10"

      tags = [
        {
          "key"                 = "k8s.io/cluster-autoscaler/enabled"
          "propagate_at_launch" = "false"
          "value"               = "true"
        },
        {
          "key"                 = "k8s.io/cluster-autoscaler/${local.cluster_name}"
          "propagate_at_launch" = "false"
          "value"               = "true"
        }
      ]
    },
  ]

  workers_additional_policies = ["arn:aws:iam::aws:policy/AutoScalingFullAccess"]
}


If someone knows where the documentation resides please comment.

🌐
Ec2spotworkshops
ec2spotworkshops.com › using_ec2_spot_instances_with_eks › 040_eksmanagednodegroupswithspot › workers_terraform.html
Create EKS managed node groups with Spot capacity :: EC2 Spot Workshops
First node group has xlarge (4 ... 2 and desired_size 1. The configuration capacity_type = “SPOT” indicates that the node group being created is an EKS managed node group with Spot capacity....
🌐
Ronamosa
ronamosa.io › eks with spot instances using terraform
EKS with Spot Instances using Terraform | The Uncommon Engineer
If you have the "best practice" setup of having each component/section of your infrastructure layout in separate folders e.g. eks in one folder, vpc in another -- and they have their own state files, which means they can't just reference each other. The solution is using terraform_remote_state data source.
🌐
GitHub
github.com › terraform-aws-modules › terraform-aws-eks › issues › 1180
Spot instances are not joined to a fresh eks 1.18.9 cluster. · Issue #1180 · terraform-aws-modules/terraform-aws-eks
AutoScalingGroups: - AutoScalingGroupARN: arn:aws:autoscaling:us-west-2:xxx:autoScalingGroup:ba201f3a-7f31-46e1-9ae0-d3f79e88cad2:autoScalingGroupName/team-shared-eks-python-spot-pool20210109234259660100000003 AutoScalingGroupName: team-shared-eks-python-spot-pool20210109234259660100000003 AvailabilityZones: - us-west-2a - us-west-2b - us-west-2c CreatedTime: '2021-01-09T23:43:01.090000+00:00' DefaultCooldown: 300 DesiredCapacity: 2 EnabledMetrics: [] HealthCheckGracePeriod: 300 HealthCheckType: EC2 Instances: - AvailabilityZone: us-west-2a HealthStatus: Healthy InstanceId: i-0ba3f2a68d9ac97ca
Published   Jan 10, 2021
Author   dmitry-mightydevops
Find elsewhere
🌐
GitHub
github.com › AKSarav › TerraformEKS-SPOT
GitHub - AKSarav/TerraformEKS-SPOT: Terraform EKS Creation with SPOT instances
Terraform EKS Creation with SPOT instances. Contribute to AKSarav/TerraformEKS-SPOT development by creating an account on GitHub.
Starred by 3 users
Forked by 15 users
Languages   HCL
🌐
DEV Community
dev.to › zenika › how-to-deploy-a-cost-efficient-awseks-kubernetes-cluster-using-terraform-in-2023-3903
☸️ How to Deploy a Cost-Efficient AWS/EKS Kubernetes Cluster Using Terraform in 2023 - DEV Community
August 31, 2024 - An AWS spot instance is an instance that uses spare EC2 capacity that is available for less than the On-Demand price. Because Spot Instances enable you to request unused EC2 instances at steep discounts, you can lower your Amazon EC2 costs ...
🌐
Medium
marcincuber.medium.com › amazon-eks-design-use-of-spot-instances-and-cluster-scaling-da7f3a72d061
Amazon EKS design, use of spot instances and cluster scaling | by Marcin Cuber | Medium
October 31, 2019 - Amazon spot instances are the unused EC2 capacity in the AWS cloud that are available to use for lower price. Spot Instances are available at up to a 90% discount compared to on-demand prices.
🌐
Sungardas
sungardas.com › en-us › cto-labs-blog › terraform-eks-and-spot-worker-nodes
Terraform, EKS and Spot Worker Nodes
April 14, 2021 - Official news, product announcements & industry updates from the 11:11 Systems experts. Stay up to date on the latest cloud, connectivity & security advice.
🌐
Timcosta
timcosta.io › creating-an-autoscaling-eks-cluster-using-spot-instances
Creating an Autoscaling EKS Cluster using AWS Spot Instances
February 2, 2020 - This will create an EKS cluster that uses t3.medium and t3.large spot instances to populate the node pool, so that if AWS raises the cost for one instance type or reclaims a node the cluster can use the other to cover the load.
🌐
GitHub
github.com › spotinst › terraform-spotinst-ocean-eks
GitHub - spotinst/terraform-spotinst-ocean-eks: [Deprecated] A Terraform module to create an Amazon Elastic Kubernetes Service (EKS) cluster with Ocean.
A Terraform module to create an Amazon Elastic Kubernetes Service (EKS) cluster with Spot Ocean.
Starred by 22 users
Forked by 30 users
Languages   HCL 99.5% | Makefile 0.5%
🌐
Ec2spotworkshops
ec2spotworkshops.com › amazon-ec2-spot-cicd-workshop › gitlab-spot › 050-deploying-eks-on-spot.html
Deploying Amazon EKS on Spot instances :: EC2 Spot Workshops
Switch to the directory with IaC templates, initialize the Terraform working directory, and apply the changes: cd ~/environment/amazon-ec2-spot-cicd-workshop/gitlab-spot/eks-cluster terraform init TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 600") export TF_VAR_aws_region=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/placement/region) curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/install/iam_policy.json export TF_VAR_alb_poli
🌐
GitHub
github.com › terraform-aws-modules › terraform-aws-eks › issues › 72
ASG workers on spot instances · Issue #72 · terraform-aws-modules/terraform-aws-eks
April 15, 2018 - I could define that one (or all) of my worker nodes ASG are using spot instances.
Published   Jul 18, 2018