jenkins-x/terraform-aws-eks-jx

Recently changes about insert a custom VPC (create_vpc = false) does't work

rupertgti opened this issue · 3 comments

Summary

When you set "create_vpc = false" because you have an existing VPC the terraform plan stops with error

Error: Reference to undeclared module

on .terraform/modules/eks-jx/modules/cluster/outputs.tf line 27, in output "eks_module":
27: value = module.cluster.eks

No module call named "cluster" is declared in module.eks-jx.module.cluster.

Steps to reproduce the behavior

Generate a clone of repository "https://github.com/jx3-gitops-repositories/jx3-terraform-eks" for yourself
In clone repository change the main.tf looks like:

module "eks-jx" {
  source              = "github.com/jenkins-x/terraform-aws-eks-jx?ref=v1.15.29"
  cluster_name        = var.cluster_name
  cluster_version     = var.cluster_version
  create_vpc          = false
  subnets             = var.subnets
  vpc_id              = var.vpc_id
  nginx_chart_version	= var.nginx_chart_version
  vault_user          = var.vault_user
  is_jx2              = false
  jx_git_url          = var.jx_git_url
  jx_bot_username     = var.jx_bot_username
  jx_bot_token        = var.jx_bot_token
  force_destroy       = var.force_destroy
  desired_node_count  = 2
  min_node_count      = 1
  max_node_count      = 3
  node_machine_type   = "t3.medium"
}

add these lines in variables.tf

variable "vpc_id" {
  description = "VPC id because we set false the create_vpc value"
  type        = string
  default     = "vpc-XXXXXXXXXXX"
}

variable "subnets" {
    description = "The subnet ids to create EKS cluster in if create_vpc is false"
    type        = list(string)
    default     = ["subnet-XXXXXXXXXX", "subnet-XXXXXXXXXXX", "subnet-XXXXXXXXXXXXX"]
}

variable "nginx_chart_version" {
  description = "required value of nginx helm chart"
  type        = string
  default     = "3.33.0"
}

Execute terraform init and terraform apply

Expected behavior

It is working :)

Actual behavior

Error: Reference to undeclared module

  on .terraform/modules/eks-jx/modules/cluster/outputs.tf line 27, in output "eks_module":
  27:   value       = module.cluster.eks

No module call named "cluster" is declared in module.eks-jx.module.cluster.

Terraform version

The output of terraform version is:

Terraform v0.13.7
+ provider registry.terraform.io/hashicorp/aws v3.44.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.2.0
+ provider registry.terraform.io/hashicorp/helm v2.1.2
+ provider registry.terraform.io/hashicorp/kubernetes v2.3.1
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/template v2.2.0

Module version

1.15.29 and 1.15.28

Operating system

Linux Ubuntu

I think the last changes need a revision:
#271
#272

This is fixed in the latest version.

Thank you!