chroma-core / chroma

the AI-native open-source embedding database
https://www.trychroma.com/
Apache License 2.0
15.44k stars 1.3k forks source link

[Bug]: Terraform init throw errors with variable reference #1135

Open Ishiihara opened 1 year ago

Ishiihara commented 1 year ago

What happened?

When running terraform init, the following error was thrown:

Initializing the backend...
Terraform encountered problems during initialisation, including problems
with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
╷
│ Error: Variables not allowed
│ 
│   on chroma.tf line 114, in resource "aws_ebs_volume" "chroma-volume":
│  114:     prevent_destroy = var.prevent_chroma_data_volume_delete # size in GBs
│ 
│ Variables may not be used here.
╵

╷
│ Error: Variables not allowed
│ 
│   on chroma.tf line 114, in resource "aws_ebs_volume" "chroma-volume":
│  114:     prevent_destroy = var.prevent_chroma_data_volume_delete # size in GBs
│ 
│ Variables may not be used here.
╵

╷
│ Error: Unsuitable value type
│ 
│   on chroma.tf line 114, in resource "aws_ebs_volume" "chroma-volume":
│  114:     prevent_destroy = var.prevent_chroma_data_volume_delete # size in GBs
│ 
│ Unsuitable value: value must be known
╵

╷
│ Error: Unsuitable value type
│ 
│   on chroma.tf line 114, in resource "aws_ebs_volume" "chroma-volume":
│  114:     prevent_destroy = var.prevent_chroma_data_volume_delete # size in GBs
│ 
│ Unsuitable value: value must be known
╵

Versions

Chroma v0.4.10

Relevant log output

Initializing the backend...
Terraform encountered problems during initialisation, including problems
with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
╷
│ Error: Variables not allowed
│ 
│   on chroma.tf line 114, in resource "aws_ebs_volume" "chroma-volume":
│  114:     prevent_destroy = var.prevent_chroma_data_volume_delete # size in GBs
│ 
│ Variables may not be used here.
╵

╷
│ Error: Variables not allowed
│ 
│   on chroma.tf line 114, in resource "aws_ebs_volume" "chroma-volume":
│  114:     prevent_destroy = var.prevent_chroma_data_volume_delete # size in GBs
│ 
│ Variables may not be used here.
╵

╷
│ Error: Unsuitable value type
│ 
│   on chroma.tf line 114, in resource "aws_ebs_volume" "chroma-volume":
│  114:     prevent_destroy = var.prevent_chroma_data_volume_delete # size in GBs
│ 
│ Unsuitable value: value must be known
╵

╷
│ Error: Unsuitable value type
│ 
│   on chroma.tf line 114, in resource "aws_ebs_volume" "chroma-volume":
│  114:     prevent_destroy = var.prevent_chroma_data_volume_delete # size in GBs
│ 
│ Unsuitable value: value must be known
╵
HammadB commented 1 year ago

@tazarov Could you TAL here?

tazarov commented 1 year ago

@Ishiihara, yeah, this is a problem with the lifecycle hook in Terraform. Ideally, we want to allow the user to control via vars whether the volume is removed or not by default, but according to Terraform's own docs the value must be known very early in the deps tree resolution so its value must be known. The issue why it passed tests is probably cached state value on my machine (typical "it works on my machine" kind of thing).

The easiest way to fix this is to configure the value in the aws_esb_volume directly:

resource "aws_ebs_volume" "chroma-volume" {
  availability_zone = aws_instance.chroma_instance.availability_zone
  size              = var.chroma_data_volume_size

  tags = {
    Name = "chroma"
  }

  lifecycle {
    prevent_destroy = false
  }
}
tazarov commented 1 year ago

@Ishiihara, fix PR is up - https://github.com/chroma-core/chroma/pull/1139

tazarov commented 1 year ago

We moved this to another PR that has better implementation #1173