1

I'm creating LogicApps with Terraform. Logic Apps will do webhook and I would like to post text.

I would like to customize text field of Terraform code with If statement. I would like to certain part of text to be displayed at only prod environment. However my terraform code with pass entire if statement to LogicApps and I get payload error with LogicApps execution.

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"
            }
    }

1 Answer 1

1

You can use conditions in your BODY as follows:

  body = <<-BODY
    {
        "blocks": [
            {
              "text": {
                "text": "Alert: ${var.environment_name == "prod" ? "*This is prod alert*" : "*---*"}",
                "type": "mrkdwn"
            }
    }
    BODY

Sign up to request clarification or add additional context in comments.

1 Comment

How to add alert text before if statement? Suggestion: "text": "Alert: " + ${var.environment_name == "prod" ? "This is prod alert" : "---"},

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.