Lambda Insights and enhanced CloudWatch event rules
New Features
Amazon CloudWatch Lambda Insights
Amazon CloudWatch Lambda Insights can now be enabled for your zip
and image
deployment packages:
module "lambda" {
// see above
cloudwatch_lambda_insights_enabled = true
}
Please check the list of supported runtimes!
This module will add the required IAM permissions to the function role automatically for both package types.
In case of a zip
deployment package, this module will also add the appropriate extension layer
to your function (use cloudwatch_lambda_insights_extension_version
to set the version of this layer).
For image
deployment packages, the Lambda Insights extension needs to be added to the container image:
FROM public.ecr.aws/serverless/extensions/lambda-insights:12 AS lambda-insights
FROM public.ecr.aws/lambda/nodejs:12
COPY --from=lambda-insights /opt /opt
COPY app.js /var/task/
CloudWatch event rules
The possibilities to declare CloudWatch Event Rules inline have been enhanced with this release.
Using the new variable cloudwatch_event_rules
you can now:
- declare N event rules instead of only one
- use a Lambda alias as the event traget
- configure all attributes of the event rules inline
- required permissions to trigger Lambda by EventBridge will be generated
module "lambda" {
// see above
cloudwatch_event_rules = {
scheduled = {
schedule_expression = "rate(1 minute)"
// optionally overwrite arguments like 'description'
// from https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule
description = "Triggered by CloudTrail"
// optionally overwrite `cloudwatch_event_target_arn` in case an alias should be used for the event rule
cloudwatch_event_target_arn = aws_lambda_alias.example.arn
}
pattern = {
event_pattern = <<PATTERN
{
"detail-type": [
"AWS Console Sign In via CloudTrail"
]
}
PATTERN
}
}
}
see example for details
Deprecations
Using the event
variable to configure the cloudwatch-event
terraform sub-module is deprecated and will be removed in the next major release. You should be able to migrate to the new variable without downtime.
What's Changed
- added support for CloudWatch Lambda Insights by @moritzzimmer in #30
Full Changelog: v5.11.0...v5.12.0