I am trying to configure a resource and i have two attributes that are dependent on the same bool variable, I am setting this up as below
resource "aws_sagemaker_endpoint_configuration" "ec" {
name = "${var.model_name}-ec"
production_variants {
variant_name = "${var.model_name}-ec-variant"
model_name = aws_sagemaker_model.model.name
dynamic "serverless_config" {
for_each = var.serverless ? [1]: []
content {
max_concurrency = 200
memory_size_in_mb = 2048
}
}
initial_instance_count = var.serverless == false ? var.initial_instance_count : null
instance_type = var.serverless == false ? var.instance_type : null
}
}
Is it possible to write the above configuration more cleanly?
if var.serverless = true
I would like the serverless_config block to be set as below
serverless_config {
max_concurrency = 200
memory_size_in_mb = 2048
}
else If var.serverless=false
I would like the below two attributes to be set
initial_instance_count = var.initial_instance_count
instance_type = var.instance_type