Skip to content

Commit

Permalink
Merge pull request #5 from PacoVK/#4-migrate-to-AL2-runtime
Browse files Browse the repository at this point in the history
#4 migrate to al2 runtime
  • Loading branch information
PacoVK authored Aug 30, 2023
2 parents 2f5655c + eb78763 commit 3675581
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# README #

### [DEPRECATION NOTICE] ###
Functionbeat has been deprecated in favor to the new [Elastic Serverless Forwarder](https://www.elastic.co/guide/en/esf/current/aws-elastic-serverless-forwarder.html). Fortunately, Elastic Serverless Forwarder ships with a [Terraform deployment capability](https://www.elastic.co/guide/en/esf/current/aws-deploy-elastic-serverless-forwarder.html#aws-serverless-forwarder-deploy-terraform).
This module will **stay maintained, but no additional features** will be added.

## What is this module for? ##

Terraform wrapper module to ship Cloudwatch Logs to Kibana via Functionbeat. See [official Docs](https://www.elastic.co/guide/en/beats/functionbeat/current/index.html). <br/>
The official Functionbeat is based on Cloudformation and also ships with a deployment CLI. If you prefer to stick to Terraform you cannot use Functionbeat alongside your infrastructure code base. This module wrapps the base function to package the Functionbeat lambda and actually deploys via Terraform.

Expand All @@ -8,6 +14,8 @@ Since this module executes a script ensure your machine has the following softwa
* jq
* curl
* tar
* zip
* unzip

### Running under Alpine ###
:information_source:
Expand Down Expand Up @@ -75,8 +83,8 @@ Head over to `example/elasticsearch/elasticsearch.tf` or `example/logstash/logs
| lambda_memory_size | - | Memory size (default: 128MB) |
| lambda_timeout | - | Timeout (default: 3s) |
| lambda_description | - | Description added to the Lambda (default: "Lambda function to ship cloudwatch logs to Kibana") |
| fb_log_level | - | Functionbeat loglevel, will be set as an ENV on the Lambda level for easy adjustion (default: info) |
| lambda_write_arn_to_ssm | - | Switch to control weather the actual Lambda ARN should be written to SSM (default:true) |
| fb_log_level | - | Functionbeat loglevel, will be set as an ENV on the Lambda level for easy adjustion (default: info) |
| fb_extra_configuration | - | HCL-Map with actual Functionbeat config (default: {}) |
| fb_extra_tags | - | The tags of the shipper are included in their own field with each transaction published (default: []) |
| loggroup_name | - | Name of the Cloudwatch log group to be added as trigger for the function (default: null) |
Expand Down
15 changes: 14 additions & 1 deletion lambda_loader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,21 @@ cp -f "${CONFIG_FILE}" "${DESTINATION}"/functionbeat.yml

cd "${DESTINATION}"
./functionbeat -v -e package --output ./../"${DESTINATION}-release".zip

cd ..
rm -rf "${DESTINATION}"

unzip -o -qq -a "${DESTINATION}"-release.zip -d "${DESTINATION}"-release
rm -rf "${DESTINATION}"-release.zip

cd "${DESTINATION}"-release
# custom runtime requires the executable to be named bootstrap
mv functionbeat-aws bootstrap
chmod go-w functionbeat.yml
cd ..

zip -j -q "${DESTINATION}"-release.zip "${DESTINATION}"-release/*
rm -rf "${DESTINATION}"-release

cd ..

jq -M -c -n --arg destination "${DESTINATION}-release.zip" '{"filename": $destination}'
12 changes: 7 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ resource "aws_lambda_function" "functionbeat" {
description = var.lambda_description
filename = data.external.lambda_loader.result.filename
source_code_hash = filebase64sha256(data.external.lambda_loader.result.filename)
handler = "functionbeat-aws"
role = aws_iam_role.lambda_execution_role.arn
runtime = "go1.x"
timeout = var.lambda_timeout
memory_size = var.lambda_memory_size
# unused by this runtime but still required
handler = "null.handler"
role = aws_iam_role.lambda_execution_role.arn
runtime = "provided.al2"
architectures = ["x86_64"]
timeout = var.lambda_timeout
memory_size = var.lambda_memory_size
vpc_config {
security_group_ids = var.lambda_config.vpc_config.security_group_ids
subnet_ids = var.lambda_config.vpc_config.subnet_ids
Expand Down

0 comments on commit 3675581

Please sign in to comment.