Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation that either email/sns topic is presented, with threshold #11

Open
EreminAnton opened this issue Oct 30, 2023 · 1 comment
Open

Comments

@EreminAnton
Copy link
Member

No description provided.

@EreminAnton
Copy link
Member Author

We can use this example for variables validations:
locals {
is_sns_or_email_set = length(var.cost_anomaly_detection_subscriber_sns_topic_arns) > 0 || length(var.cost_anomaly_detection_subscriber_email_addresses) > 0
is_threshold_set = var.cost_anomaly_detection_threshold != null
should_create = var.create_cost_anomaly_detection_alert

validate_condition = local.should_create && (!local.is_sns_or_email_set || !local.is_threshold_set)
validation_message = "If create_cost_anomaly_detection_alert is set to true, either SNS or email must be set, and the threshold must be non-null."

validate_check = regex(
"^${local.validation_message}$",
( !local.validate_condition
? local.validation_message
: "" ) )
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant