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 #239

Closed
wants to merge 3 commits into from
Closed

Remove type constraint to allow null #239

wants to merge 3 commits into 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::git@inhouse.net: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::git@github.com: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

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Thomas Guthmann seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA. If you already have a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

@TomGudman
Copy link
Author

And replaced again by #240 the third time the charm!

@TomGudman TomGudman closed this Dec 30, 2021
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.

2 participants