1
votes

My terraform version is v0.11.13. I use resource "aws_launch_template" for resource "aws_eks_node_group". I got the error, "invalid or unknown key: launch_template".

Error: module.eks_node_windows_group.aws_eks_node_group.windows-worker-nodes-group: : invalid or unknown key: launch_template.

Below is the relevant code:

resource "aws_launch_template" "worker-node-windows" {
  image_id               = "ami-0e6430de0e2d50a33"
  name                   = "windows_node"
  update_default_version = true
}

resource "aws_eks_node_group" "windows-worker-nodes-group" {
  cluster_name    = "${var.eks_cluster_name}"
  node_group_name = "${var.eks_cluster_node_group_name}"
  node_role_arn   = "${var.eks_worker_node_role_arn}"
  subnet_ids      = ["${var.eks_worker_subnet_ids}"]
  ami_type        = "${var.ami_type}"
  instance_types  = "${var.instance_type}"
  disk_size       = "${var.volume_size}"
  release_version = "${var.release_version}"
  version         = "${var.eks_cluster_version}"

  launch_template {
    name    = "${aws_launch_template.worker-node-windows.name}"
    version = "${aws_launch_template.worker-node-windows.latest_version}"
    id      = "${aws_launch_template.worker-node-windows.id}"
  }
}
1

1 Answers

2
votes

The launch_template for aws_eks_node_group was introduced in version 3.3.0 of the Terraform AWS Provider.

Make sure that you use at least version 3.3.0 of the aws provider (see docs for terraform 0.11):

provider "aws" {
  version = ">= 3.3.0"
  region  = "us-east-1"
}

and then run terraform init