[英]How to create if statement in Terraform for LogicApps
I'm creating LogicApps with Terraform.我正在使用 Terraform 创建 LogicApps。 Logic Apps will do webhook and I would like to post text. Logic Apps 将做 webhook,我想发布文本。
I would like to customize text field of Terraform code with If statement.我想用 If 语句自定义 Terraform 代码的文本字段。 I would like to certain part of text to be displayed at only prod environment.我想仅在 prod 环境中显示文本的某些部分。 However my terraform code with pass entire if statement to LogicApps and I get payload error with LogicApps execution.但是,我的 terraform 代码将整个 if 语句传递给 LogicApps,并且我在执行 LogicApps 时遇到有效负载错误。
resource "azurerm_logic_app_action_http" "example" {
name = "webhook"
logic_app_id = azurerm_logic_app_workflow.example.id
method = "GET"
uri = "http://example.com/some-webhook"
method = "POST"
headers = { "Content-Type" = "application/json" }
body = <<-BODY
{
"blocks": [
{
"text": {
"text": "[${var.environment_name}] == "prod" ? *This is prod alert* : *---*",
"type": "mrkdwn"
}
}
You can use conditions in your BODY
as follows:您可以在您的BODY
使用条件,如下所示:
body = <<-BODY
{
"blocks": [
{
"text": {
"text": "Alert: ${var.environment_name == "prod" ? "*This is prod alert*" : "*---*"}",
"type": "mrkdwn"
}
}
BODY
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.