Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Remove type constraint to allow null #240

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TomGudman
Copy link

Description

When you use terragrunt or even a terraform module calling terraform-aws-consul module you may have spot_price defined but you don't want to assign any value because you want the instances to be on-demand. However since it's templated with the use of a variable, spot_price is always present. Unfortunately the type=number for spot_price makes it impossible to assign an empty value because terraform/terragrunt will tell you that null or "" is not a number.

The change is a simple as not enforcing the type = number in variables.tf

Use case (simplified version)

terragrunt.hcl

terraform {
  source = "git::[email protected]:infrastructure/terraform-modules/cloud-modules.git///aws-consul-server-cluster/"
}
...
inputs = {
  ...
  cluster_name   = "foobar"
  spot_price   = local.SPOT
  ...
}

terraform in-house module

variable "spot_price" {
  description = "If defined, let's use spot instances with a price UP TO this value"
  default     = null
}

module "consul_servers" {
  source = "git::[email protected]:TomGudman/terraform-aws-consul.git//modules/consul-cluster?ref=v0.11.1"

  cluster_name  = var.cluster_name
  cluster_size  = var.num_servers
  instance_type = var.instance_type

  spot_price = var.spot_price
}

Documentation

N/A

TODOs / Related issues

There isn't any issue number yet and I couldn't find one.

@hashicorp-cla
Copy link

hashicorp-cla commented Mar 12, 2022

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

3 participants