mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-02-22 18:47:48 +01:00
Additional support for Terraform v0.13 and aws v3! - The update to the vpc module in examples was, strictly speaking, unnecessary but it adds the terraform block with supported versions. - Update for iam module in the example was very necessary to support new versions - Workaround for "Provider produced inconsistent final plan" when creating ASGs at the same time as the cluster. See https://github.com/terraform-providers/terraform-provider-aws/issues/14085 for full details. - Blacklist 0.13.0 as it was too strict when migrating from aws v2 to v3 about dropped attributes.
84 lines
1.8 KiB
HCL
84 lines
1.8 KiB
HCL
terraform {
|
|
required_version = ">= 0.12.2"
|
|
}
|
|
|
|
provider "aws" {
|
|
version = ">= 2.28.1"
|
|
region = var.region
|
|
}
|
|
|
|
provider "random" {
|
|
version = "~> 2.1"
|
|
}
|
|
|
|
provider "local" {
|
|
version = "~> 1.2"
|
|
}
|
|
|
|
provider "null" {
|
|
version = "~> 2.1"
|
|
}
|
|
|
|
provider "template" {
|
|
version = "~> 2.1"
|
|
}
|
|
|
|
data "aws_eks_cluster" "cluster" {
|
|
name = module.eks.cluster_id
|
|
}
|
|
|
|
data "aws_eks_cluster_auth" "cluster" {
|
|
name = module.eks.cluster_id
|
|
}
|
|
|
|
provider "kubernetes" {
|
|
host = data.aws_eks_cluster.cluster.endpoint
|
|
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
|
|
token = data.aws_eks_cluster_auth.cluster.token
|
|
load_config_file = false
|
|
version = "~> 1.11"
|
|
}
|
|
|
|
data "aws_availability_zones" "available" {
|
|
}
|
|
|
|
locals {
|
|
cluster_name = "test-eks-spot-${random_string.suffix.result}"
|
|
}
|
|
|
|
resource "random_string" "suffix" {
|
|
length = 8
|
|
special = false
|
|
}
|
|
|
|
module "vpc" {
|
|
source = "terraform-aws-modules/vpc/aws"
|
|
version = "2.47.0"
|
|
|
|
name = "test-vpc-spot"
|
|
cidr = "10.0.0.0/16"
|
|
azs = data.aws_availability_zones.available.names
|
|
public_subnets = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"]
|
|
enable_dns_hostnames = true
|
|
}
|
|
|
|
module "eks" {
|
|
source = "../.."
|
|
cluster_name = local.cluster_name
|
|
cluster_version = "1.17"
|
|
subnets = module.vpc.public_subnets
|
|
vpc_id = module.vpc.vpc_id
|
|
|
|
worker_groups_launch_template = [
|
|
{
|
|
name = "spot-1"
|
|
override_instance_types = ["m5.large", "m5a.large", "m5d.large", "m5ad.large"]
|
|
spot_instance_pools = 4
|
|
asg_max_size = 5
|
|
asg_desired_capacity = 5
|
|
kubelet_extra_args = "--node-labels=node.kubernetes.io/lifecycle=spot"
|
|
public_ip = true
|
|
},
|
|
]
|
|
}
|