Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rupertgti opened this issue Jun 9, 2021 · 3 comments

Comments

@rupertgti
Copy link
Contributor

rupertgti commented Jun 9, 2021

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
@rupertgti
Copy link
Contributor Author

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

@ankitm123
Copy link
Member

This is fixed in the latest version.

@rupertgti
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants