Skip to content

Commit 95639b1

Browse files
committed
terraform_plan/provider_config: Send error=2 when region isn't provided
1 parent 6d27c09 commit 95639b1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/tirith/providers/terraform_plan/handler.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,20 @@ def provider_config_operator(input_data: dict, provider_inputs: dict, outputs: l
230230
return
231231
outputs.append({"value": version_constraint, "meta": provider_config_dict})
232232
elif attribute_to_get == "region":
233-
# TODO: The region might not be in the constant_value, it can be in a variable
233+
# FIXME: The region might not be in the constant_value, it can be in a variable
234+
region = provider_config_dict.get("expressions", {}).get("region", {}).get("constant_value")
235+
if region is None:
236+
outputs.append(
237+
{
238+
"value": ProviderError(severity_value=2),
239+
"err": f"region is not found in the provider_config (severity_value: 2)",
240+
"meta": provider_config_dict,
241+
}
242+
)
243+
return
234244
outputs.append(
235245
{
236-
"value": provider_config_dict.get("expressions", {}).get("region", {}).get("constant_value"),
246+
"value": region,
237247
"meta": provider_config_dict,
238248
}
239249
)

0 commit comments

Comments
 (0)