_An AWS Lambda for sending EventBridge events to API endpoint
The goal of this module is to send a POST to a specific API endpoint when an EventBridge rule is triggered.
The lambda function payload is an object with the following type:
type Payload = {
headers: {
"Authorization": string,
[key: string]: string
};
data: JSON;
};
headers
: Need at least the key Authorization
to access the API
data
: All the data you want to send to the API. Can be empty
Add the module to your Terraform project:
module "eventbridge_logger_opgenie" {
source = "github.com/agendrix/eventbridge-to-make-api-call.git//terraform?ref=v0.1.2"
sns_topic_to_notify_on_failure = <aws_sns_topic_arn>
name = "Ressource Name"
api_config = {
api_url = "<MY_API_URL>"
api_key = "<MY_API_KEY_SECRET>"
}
event_pattern = jsonencode({
source = ["aws.cloudwatch"]
detail-type = ["CloudWatch Alarm State Change"]
})
input_transformer = {
input_paths = {
source = "$.source"
time = "$.time"
alarm = "$.detail.alarmName"
}
input_template = <<EOF
{
"headers": {
"Content-Type": "application/json",
"Authorization": "Key "
},
"data": {
"message": "My Message <source>",
"description": "My Description: <time> <alarm>",
}
}
EOF
}
}