Sharjeel
Sharjeel

Reputation: 290

Override a module's local.tf variable in Terraform

I want to override the value of root_volume_type to gp2 in https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/local.tf

This is the only file I created called main.tf in my terraform code. I want to override this in the code and not set it via the command line while running terraform apply

module "eks_example_basic" {
  source  = "terraform-aws-modules/eks/aws//examples/basic"
  version = "14.0.0"
  region  = "us-east-1"
}

Upvotes: 0

Views: 2706

Answers (1)

Marcin
Marcin

Reputation: 238687

The error is correct because you are sourcing an example, which does not support such variables as workers_group_defaults. You can't overwrite it, unless you fork the example and modify it yourself.

workers_group_defaults is supported in the core module, for instance:

data "aws_vpc" "default" {
  default = true
}

data "aws_subnet_ids" "default" {
  vpc_id = data.aws_vpc.default.id
}

module "eks_example" { 

  source = "terraform-aws-modules/eks/aws" 
  
  version = "14.0.0"  
  cluster_name = "SomeEKSCluster"  
  cluster_version = "1.18"
 
  subnets         = data.aws_subnet_ids.default.ids
  vpc_id          = data.aws_vpc.default.id    
      
  workers_group_defaults = { root_volume_type = "gp2" }
}      


Upvotes: 2

Related Questions