Skip to content

Commit

Permalink
terraform_plan/provider_config: Send error=2 when region isn't provided
Browse files Browse the repository at this point in the history
  • Loading branch information
refeed committed Feb 9, 2024
1 parent 6d27c09 commit 95639b1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/tirith/providers/terraform_plan/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,20 @@ def provider_config_operator(input_data: dict, provider_inputs: dict, outputs: l
return
outputs.append({"value": version_constraint, "meta": provider_config_dict})
elif attribute_to_get == "region":
# TODO: The region might not be in the constant_value, it can be in a variable
# FIXME: The region might not be in the constant_value, it can be in a variable
region = provider_config_dict.get("expressions", {}).get("region", {}).get("constant_value")
if region is None:
outputs.append(
{
"value": ProviderError(severity_value=2),
"err": f"region is not found in the provider_config (severity_value: 2)",
"meta": provider_config_dict,
}
)
return
outputs.append(
{
"value": provider_config_dict.get("expressions", {}).get("region", {}).get("constant_value"),
"value": region,
"meta": provider_config_dict,
}
)
Expand Down

0 comments on commit 95639b1

Please sign in to comment.