Skip to content

[TF] Update AWS and required TF versions, support al2 images for Lambdas, and arm64 Lambda support#40

Merged
rdiers merged 1 commit into
airbnb:masterfrom
rdiers:master
Nov 29, 2023
Merged

[TF] Update AWS and required TF versions, support al2 images for Lambdas, and arm64 Lambda support#40
rdiers merged 1 commit into
airbnb:masterfrom
rdiers:master

Conversation

@rdiers

@rdiers rdiers commented Sep 5, 2023

Copy link
Copy Markdown
Contributor

to: @airbnb/rudolph-maintainers

Background

This PR seeks to adopt the changes as AWS is seeking to deprecate al1 backed Lambdas by end of year 2023...ref: https://aws.amazon.com/blogs/compute/migrating-aws-lambda-functions-from-the-go1-x-runtime-to-the-custom-runtime-on-amazon-linux-2/.

Changes

Testing

Deployed to personal development AWS account:

Screenshot 2023-09-05 at 08 22 32

Comment thread Makefile
VERSION := $(shell git describe --tags --always)
DOCS_DIR ?= ./docs
DEPLOYMENT_ZIP_PATH = $(PWD)/build/package/deployment.zip
RUDOLPH_API_DEPLOYMENT_ZIP_PATH = $(PWD)/build/package/api_deployment.zip

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since each zip now needs to contain a singular binary called bootstrap this is required to split each handler into its own zip...

provider "aws" {
region = "us-east-1"
default_tags {
tags = {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the README doc from the previous PR #39

lambda_zip = var.zip_file_path
package_version = var.package_version

lambda_api_zip = var.lambda_api_zip

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provide each zip folder location now

}

variable "lambda_zip" {
variable "lambda_api_zip" {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TF vars for zip locations

etag = filemd5(var.lambda_api_zip)
}

resource "aws_s3_bucket_object" "santa_api_authorizer_source" {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the authorizer as a separate s3 bucket object

lambda_source_bucket = aws_s3_bucket_object.santa_api_source.bucket
lambda_source_key = aws_s3_bucket_object.santa_api_source.key
lambda_source_hash = local.lambda_source_hash
lambda_handler = "api"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since handlers for al2.provided images must just be called bootstrap this var is no longer needed


# Use the authorizer's UsageIdentifierKey to uniquely identify an endpoint.
api_key_source = "AUTHORIZER"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

type = string
description = "Lambda function handler path. If left blank, this will default to a formatted handler based on the endpoint variable value"
default = ""
default = "bootstrap"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

al2.provided requires that the executing binary be called bootstrap to execute properly

locals {
handler = var.lambda_handler == "" ? var.endpoint : var.lambda_handler
handler = "bootstrap"
runtime = "provided.al2"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above.

Comment thread scripts/build.sh
CLI_NAME=rudolph
PKG_DIR=$BUILD_DIR/package
DEPLOYMENT_ZIP_PATH=$PKG_DIR/deployment.zip
API_DEPLOYMENT_ZIP_PATH=$PKG_DIR/api_deployment.zip

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the build scripts to reflect to lambda handler output zips being created:

  • API handler
  • API authorizer handler

@rdiers rdiers requested review from MarkVLK and Ryxias September 5, 2023 15:32
@rdiers rdiers marked this pull request as ready for review September 5, 2023 15:32

@Ryxias Ryxias left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

function_name = "${var.prefix}_rudolph_${var.endpoint}"
role = aws_iam_role.api_handler_role.arn
handler = local.handler
runtime = "go1.x"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Ryxias

Ryxias commented Sep 5, 2023

Copy link
Copy Markdown
Collaborator

Should cut a new release for this, maybe 0.2.0 or something. The deprecation of go1.x is a pretty big deal

@rdiers rdiers merged commit 7dad3d6 into airbnb:master Nov 29, 2023
@rdiers rdiers self-assigned this Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants