Skip to content

Commit 3675581

Browse files
authored
Merge pull request #5 from PacoVK/#4-migrate-to-AL2-runtime
#4 migrate to al2 runtime
2 parents 2f5655c + eb78763 commit 3675581

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# README #
22

3+
### [DEPRECATION NOTICE] ###
4+
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).
5+
This module will **stay maintained, but no additional features** will be added.
6+
7+
## What is this module for? ##
8+
39
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/>
410
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.
511

@@ -8,6 +14,8 @@ Since this module executes a script ensure your machine has the following softwa
814
* jq
915
* curl
1016
* tar
17+
* zip
18+
* unzip
1119

1220
### Running under Alpine ###
1321
:information_source:
@@ -75,8 +83,8 @@ Head over to `example/elasticsearch/elasticsearch.tf` or `example/logstash/logs
7583
| lambda_memory_size | - | Memory size (default: 128MB) |
7684
| lambda_timeout | - | Timeout (default: 3s) |
7785
| lambda_description | - | Description added to the Lambda (default: "Lambda function to ship cloudwatch logs to Kibana") |
78-
| fb_log_level | - | Functionbeat loglevel, will be set as an ENV on the Lambda level for easy adjustion (default: info) |
7986
| lambda_write_arn_to_ssm | - | Switch to control weather the actual Lambda ARN should be written to SSM (default:true) |
87+
| fb_log_level | - | Functionbeat loglevel, will be set as an ENV on the Lambda level for easy adjustion (default: info) |
8088
| fb_extra_configuration | - | HCL-Map with actual Functionbeat config (default: {}) |
8189
| fb_extra_tags | - | The tags of the shipper are included in their own field with each transaction published (default: []) |
8290
| loggroup_name | - | Name of the Cloudwatch log group to be added as trigger for the function (default: null) |

lambda_loader.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,21 @@ cp -f "${CONFIG_FILE}" "${DESTINATION}"/functionbeat.yml
2323

2424
cd "${DESTINATION}"
2525
./functionbeat -v -e package --output ./../"${DESTINATION}-release".zip
26-
2726
cd ..
2827
rm -rf "${DESTINATION}"
2928

29+
unzip -o -qq -a "${DESTINATION}"-release.zip -d "${DESTINATION}"-release
30+
rm -rf "${DESTINATION}"-release.zip
31+
32+
cd "${DESTINATION}"-release
33+
# custom runtime requires the executable to be named bootstrap
34+
mv functionbeat-aws bootstrap
35+
chmod go-w functionbeat.yml
36+
cd ..
37+
38+
zip -j -q "${DESTINATION}"-release.zip "${DESTINATION}"-release/*
39+
rm -rf "${DESTINATION}"-release
40+
41+
cd ..
42+
3043
jq -M -c -n --arg destination "${DESTINATION}-release.zip" '{"filename": $destination}'

main.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ resource "aws_lambda_function" "functionbeat" {
3131
description = var.lambda_description
3232
filename = data.external.lambda_loader.result.filename
3333
source_code_hash = filebase64sha256(data.external.lambda_loader.result.filename)
34-
handler = "functionbeat-aws"
35-
role = aws_iam_role.lambda_execution_role.arn
36-
runtime = "go1.x"
37-
timeout = var.lambda_timeout
38-
memory_size = var.lambda_memory_size
34+
# unused by this runtime but still required
35+
handler = "null.handler"
36+
role = aws_iam_role.lambda_execution_role.arn
37+
runtime = "provided.al2"
38+
architectures = ["x86_64"]
39+
timeout = var.lambda_timeout
40+
memory_size = var.lambda_memory_size
3941
vpc_config {
4042
security_group_ids = var.lambda_config.vpc_config.security_group_ids
4143
subnet_ids = var.lambda_config.vpc_config.subnet_ids

0 commit comments

Comments
 (0)