I'm trying to follow this Gitlab tutorial for deploying CI runners within EKS using Terraform and an example project. When I cloned the project repo I ran the below commands.
terraform fmt
terraform init -upgrade
I also changed backend
to local
within the backend.tf
file.
terraform {
backend "local" {
}
}
I am getting errors within the validate
stage stating that variables within my eks
module are not expected. From what I can see from reading around, the config appears to be correct.
Any idea what I am doing wrong here?
// eks.tf
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "18.1.0"
cluster_name = var.cluster_name
cluster_version = var.cluster_version
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
eks_managed_node_groups = {
default = {
min_size = 1
max_size = var.instance_count
desired_size = var.instance_count
instance_types = [var.instance_type]
}
}
}
Error:
$ gitlab-terraform validate
Initializing modules...
Initializing provider plugins...
- Reusing previous version of hashicorp/helm from the dependency lock file
- Reusing previous version of hashicorp/aws from the dependency lock file
- Reusing previous version of hashicorp/kubernetes from the dependency lock file
- Installing hashicorp/kubernetes v2.22.0...
- Installed hashicorp/kubernetes v2.22.0 (signed by HashiCorp)
- Installing hashicorp/helm v2.10.1...
- Installed hashicorp/helm v2.10.1 (signed by HashiCorp)
- Installing hashicorp/aws v5.8.0...
- Installed hashicorp/aws v5.8.0 (signed by HashiCorp)
Terraform has made some changes to the provider dependency selections recorded
in the .terraform.lock.hcl file. Review those changes and commit them to your
version control system if they represent changes you intended to make.
Terraform has been successfully initialized!
╷
│ Error: Unsupported argument
│
│ on eks.tf line 5, in module "eks":
│ 5: cluster_name = var.cluster_name
│
│ An argument named "cluster_name" is not expected here.
╵
╷
│ Error: Unsupported argument
│
│ on eks.tf line 6, in module "eks":
│ 6: cluster_version = var.cluster_version
│
│ An argument named "cluster_version" is not expected here.
╵
╷
│ Error: Unsupported argument
│
│ on eks.tf line 8, in module "eks":
│ 8: vpc_id = module.vpc.vpc_id
│
│ An argument named "vpc_id" is not expected here.
╵
╷
│ Error: Unsupported argument
│
│ on eks.tf line 9, in module "eks":
│ 9: subnet_ids = module.vpc.private_subnets
│
│ An argument named "subnet_ids" is not expected here.
╵
╷
│ Error: Unsupported argument
│
│ on eks.tf line 11, in module "eks":
│ 11: eks_managed_node_groups = {
│
│ An argument named "eks_managed_node_groups" is not expected here.
╵
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1
Project structure and files:
❯ tree
.
├── README.md
├── agent.tf
├── backend.tf
├── data.tf
├── eks.tf
├── outputs.tf
├── providers.tf
├── variables.tf
├── versions.tf
└── vpc.tf
This probably is due to the mismatch of your Terraform version and the library version.
I can plan your code just fine with the module version 19.15.3 and Terraform v1.5.3 (took out the variables):
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "19.15.3"
cluster_name = "test"
cluster_version = "1.27"
vpc_id = "vpc-123"
subnet_ids = ["subnet-123"]
eks_managed_node_groups = {
default = {
min_size = 1
max_size = 1
desired_size = 1
instance_types = ["t2.micro"]
}
}
}