From 300d758774648e92df0aaee8964ebaf39cd559fb Mon Sep 17 00:00:00 2001 From: Pascal Euhus Date: Wed, 30 Aug 2023 19:13:46 +0200 Subject: [PATCH 1/4] order input params --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc27eba..b935c93 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,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) | From bde486cb9ed76eca07f00a460f18cf108d75b834 Mon Sep 17 00:00:00 2001 From: Pascal Euhus Date: Wed, 30 Aug 2023 21:47:47 +0200 Subject: [PATCH 2/4] migrate to provided.al2 --- lambda_loader.sh | 15 ++++++++++++++- main.tf | 6 ++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lambda_loader.sh b/lambda_loader.sh index 3f097fd..b0d4fa5 100755 --- a/lambda_loader.sh +++ b/lambda_loader.sh @@ -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}' diff --git a/main.tf b/main.tf index 13a356d..37ce97a 100644 --- a/main.tf +++ b/main.tf @@ -31,9 +31,11 @@ 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" + # unused by this runtime but still required + handler = "null.handler" role = aws_iam_role.lambda_execution_role.arn - runtime = "go1.x" + runtime = "provided.al2" + architectures = ["x86_64"] timeout = var.lambda_timeout memory_size = var.lambda_memory_size vpc_config { From 2420d3344f8a0ded2aacc4625f7b6979dc570a8b Mon Sep 17 00:00:00 2001 From: Pascal Euhus Date: Wed, 30 Aug 2023 21:48:22 +0200 Subject: [PATCH 3/4] Update docs and deprecate --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index b935c93..f0956a1 100644 --- a/README.md +++ b/README.md @@ -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).
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. @@ -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: From eb787635f123db37e8e1a378721f8e34dcbb7a7e Mon Sep 17 00:00:00 2001 From: Pascal Euhus Date: Wed, 30 Aug 2023 21:50:55 +0200 Subject: [PATCH 4/4] fmt --- main.tf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.tf b/main.tf index 37ce97a..213f6f4 100644 --- a/main.tf +++ b/main.tf @@ -32,12 +32,12 @@ resource "aws_lambda_function" "functionbeat" { filename = data.external.lambda_loader.result.filename source_code_hash = filebase64sha256(data.external.lambda_loader.result.filename) # 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 + 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