alicloud_event_bridge_rule

Provides a Event Bridge Rule resource.

For information about Event Bridge Rule and how to use it, see What is Rule.

Example Usage

Basic Usage

variable "name" {
  default = "tf-example"
}

data "alicloud_regions" "default" {
  current = true
}

data "alicloud_account" "default" {
}

resource "alicloud_event_bridge_event_bus" "default" {
  event_bus_name = var.name
}

resource "alicloud_mns_queue" "default" {
  name = var.name
}

resource "alicloud_event_bridge_rule" "example" {
  event_bus_name = alicloud_event_bridge_event_bus.default.event_bus_name
  rule_name      = var.name
  filter_pattern = <<EOF
{
    "source": [
        "crmabc.newsletter"
    ],
    "type": [
        "UserSignUp",
        "UserLogin"
    ]
}
    EOF
  description    = var.name
  targets {
    target_id           = "tf-example"
    type                = "http"
    endpoint            = "http://www.aliyun.com"
    push_retry_strategy = "EXPONENTIAL_DECAY_RETRY"
    dead_letter_queue {
      arn = local.mns_endpoint
    }
    param_list {
      resource_key = "Body"
      form         = "ORIGINAL"
    }
    param_list {
      resource_key = "url"
      form         = "CONSTANT"
      value        = "http://www.aliyun.com"
    }
    param_list {
      resource_key = "Network"
      form         = "CONSTANT"
      value        = "PublicNetwork"
    }
  }
}

locals {
  mns_endpoint = format("acs:mns:%s:%s:queues/%s", data.alicloud_regions.default.regions.0.id, data.alicloud_account.default.id, alicloud_mns_queue.default.name)
}
{
    "source": [
        "crmabc.newsletter"
    ],
    "type": [
        "UserSignUp",
        "UserLogin"
    ]
}
    EOF
  description    = var.name
  targets {
    target_id           = "tf-example"
    type                = "http"
    endpoint            = "http://www.aliyun.com"
    push_retry_strategy = "EXPONENTIAL_DECAY_RETRY"
    dead_letter_queue {
      arn = local.mns_endpoint
    }
    param_list {
      resource_key = "Body"
      form         = "ORIGINAL"
    }
    param_list {
      resource_key = "url"
      form         = "CONSTANT"
      value        = "http://www.aliyun.com"
    }
    param_list {
      resource_key = "Network"
      form         = "CONSTANT"
      value        = "PublicNetwork"
    }
  }
}

locals {
  mns_endpoint = format("acs:mns:%s:%s:queues/%s", data.alicloud_regions.default.regions.0.id, data.alicloud_account.default.id, alicloud_mns_queue.default.name)
}

Argument Reference

The following arguments are supported:

targets

The targets supports the following:

targets-dead_letter_queue

The dead_letter_queue supports the following:

targets-param_list

The param_list supports the following:

param_list {
  resource_key = "IsBase64Encode"
  form         = "CONSTANT"
  value        = "false"
  template     = ""
}

In order to fix the diff, from version 1.160.0, this resource has removed the param which resource_key = "IsBase64Encode" and value = "false". If you want to set resource_key = "IsBase64Encode", please avoid to set value = "false".

Attributes Reference

The following attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

Event Bridge Rule can be imported using the id, e.g.

$ terraform import alicloud_event_bridge_rule.example <event_bus_name>:<rule_name>