I'm using Terraform and noticed that one of my variables always falls back to its default value, even though I define a different value in a locals block.
Here’s what I have in variables.tf:
variable "peak_number_of_shards" {
type = number
description = "Number of shards that Kinesis stream will have under load"
default = 4
}
What I have in my prod/locals.tf:
locals {
peak_number_of_shards = 16
...
}
In my eu-west-1.tf file:
peak_number_of_shards = local.peak_number_of_shards
In my State Machine I am using like that:
ScaleUpKinesisStream = {
Comment = "State to scale Kinesis stream up synchronously"
Type = "Task"
Resource = "arn:aws:states:::states:startExecution.sync"
Parameters = {
StateMachineArn = aws_sfn_state_machine.xxx.id
Input = {
stream_name = aws_kinesis_stream.xxx.name
target_shard_count = var.peak_number_of_shards
}
}
Next = "CheckDateParameters"
Catch = [{
ErrorEquals = ["States.ALL"]
Next = "NotifyError"
}]
}
However, when I run terraform plan or terraform apply, it always uses the default value 4, not the value from the local. Other attributes are fine, sometimes some of the attributes fallbacks to the default values in some way but I couldn't understand the reason.
Terraform v0.13.7
target_shard_count = var.peak_number_of_shards. So it's actually not using the local variable, rather the default value assigned to thepeak_number_of_shardsvariable.