-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Only merge using a merge commit!**
- Loading branch information
Showing
8 changed files
with
123 additions
and
87 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,56 @@ | ||
# Related: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html | ||
|
||
resource "aws_cloudwatch_metric_alarm" "api_gateway_5xx_error" { | ||
alarm_name = "api-gateway-5xx-error" | ||
|
||
namespace = "AWS/ApiGateway" | ||
metric_name = "5XXError" | ||
# Related: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-metrics-and-dimensions.html | ||
dimensions = { | ||
ApiName = aws_api_gateway_rest_api.main.name | ||
} | ||
|
||
statistic = "Sum" | ||
comparison_operator = "GreaterThanOrEqualToThreshold" | ||
threshold = 1 | ||
evaluation_periods = 1 | ||
datapoints_to_alarm = 1 | ||
period = 60 | ||
alarm_description = "This alarm helps to detect a high rate of server-side errors. This can indicate that there is something wrong on the API backend, the network, or the integration between the API gateway and the backend API." | ||
|
||
alarm_actions = [] | ||
alarm_name = "api-gateway-5xx-error" | ||
|
||
namespace = "AWS/ApiGateway" | ||
metric_name = "5XXError" | ||
# Related: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-metrics-and-dimensions.html | ||
dimensions = { | ||
ApiName = aws_api_gateway_rest_api.main.name | ||
} | ||
|
||
statistic = "Sum" | ||
comparison_operator = "GreaterThanOrEqualToThreshold" | ||
threshold = 1 | ||
evaluation_periods = 1 | ||
datapoints_to_alarm = 1 | ||
period = 60 | ||
alarm_description = "This alarm helps to detect a high rate of 500er responses in any API Gateway." | ||
|
||
alarm_actions = [] | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "lambda_throttles" { | ||
alarm_name = "lambda-throttles" | ||
alarm_name = "lambda-throttles" | ||
|
||
namespace = "AWS/Lambda" | ||
metric_name = "Throttles" | ||
namespace = "AWS/Lambda" | ||
metric_name = "Throttles" | ||
|
||
statistic = "Sum" | ||
comparison_operator = "GreaterThanOrEqualToThreshold" | ||
threshold = 1 | ||
evaluation_periods = 1 | ||
datapoints_to_alarm = 1 | ||
period = 60 | ||
alarm_description = "This alarm detects a high number of throttled invocation requests. Throttling occurs when there is no concurrency is available for scale up. There are several approaches to resolve this issue. 1) Request a concurrency increase from AWS Support in this Region. 2) Identify performance issues in the function to improve the speed of processing and therefore improve throughput. 3) Increase the batch size of the function, so that more messages are processed by each function invocation." | ||
statistic = "Sum" | ||
comparison_operator = "GreaterThanOrEqualToThreshold" | ||
threshold = 1 | ||
evaluation_periods = 1 | ||
datapoints_to_alarm = 1 | ||
period = 60 | ||
alarm_description = "This alarm detects a high number of throttled invocation requests for any Lambda function." | ||
|
||
alarm_actions = [] | ||
alarm_actions = [] | ||
} | ||
|
||
resource "aws_cloudwatch_metric_alarm" "lambda_errors" { | ||
alarm_name = "lambda-errors" | ||
|
||
namespace = "AWS/Lambda" | ||
metric_name = "Errors" | ||
|
||
statistic = "Sum" | ||
comparison_operator = "GreaterThanOrEqualToThreshold" | ||
threshold = 1 | ||
evaluation_periods = 1 | ||
datapoints_to_alarm = 1 | ||
period = 60 | ||
alarm_description = "This alarm detects a high number of errors for any Lambda function." | ||
|
||
alarm_actions = [] | ||
} |
44 changes: 19 additions & 25 deletions
44
terraform/modules/api-gateway-eventbridge-lambda/eventbridge.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
# resource "aws_cloudwatch_event_rule" "main" { | ||
# event_bus_name = var.event_bus.arn | ||
resource "aws_cloudwatch_event_rule" "main" { | ||
event_bus_name = var.event_bus.arn | ||
|
||
# event_pattern = jsonencode({ | ||
# detail-type = [ | ||
# var.event_bus_detail_type | ||
# ] | ||
# }) | ||
event_pattern = jsonencode({ | ||
detail-type = [ | ||
var.event_bus_detail_type | ||
] | ||
}) | ||
} | ||
|
||
# # TODO | ||
# # role_arn = "" | ||
# } | ||
resource "aws_cloudwatch_event_target" "main" { | ||
rule = aws_cloudwatch_event_rule.main.name | ||
arn = aws_lambda_function.main.arn | ||
event_bus_name = var.event_bus.arn | ||
} | ||
|
||
# resource "aws_cloudwatch_event_target" "main" { | ||
# rule = aws_cloudwatch_event_rule.main.name | ||
# arn = aws_lambda_function.main.arn | ||
# event_bus_name = var.event_bus.arn | ||
|
||
# run_command_targets { | ||
# key = "tag:Name" | ||
# values = ["FooBar"] | ||
# } | ||
|
||
# run_command_targets { | ||
# key = "InstanceIds" | ||
# values = ["i-162058cd308bffec2"] | ||
# } | ||
# } | ||
resource "aws_lambda_permission" "api_gateway" { | ||
action = "lambda:InvokeFunction" | ||
function_name = aws_lambda_function.main.function_name | ||
principal = "events.amazonaws.com" | ||
source_arn = aws_cloudwatch_event_rule.main.arn | ||
} |