nelhage / llama

Apache License 2.0
589 stars 24 forks source link

ARM64 support #61

Open lichray opened 1 year ago

lichray commented 1 year ago

An ARM-native Linux machine/WSL2 should also benefit from ARM64 lambda in AWS.

llama installs and runs fine on my machine. However, the rest are probably not prepared for ARM64. For example, I cannot tell how to build an ARM64 function runtime similar to https://github.com/users/nelhage/packages/container/package/llama.

Assuming we can do that, I don't know what else is missing, if any, such as a code change in Go.

Thank you for helping!

zhihaoy commented 1 year ago

I made some progress:

diff --git a/cmd/llama/internal/function/lambda.go b/cmd/llama/internal/function/lambda.go
index 32b1015..30ec2d6 100644
--- a/cmd/llama/internal/function/lambda.go
+++ b/cmd/llama/internal/function/lambda.go
@@ -52,6 +52,9 @@ func createOrUpdateFunction(ctx context.Context, g *cli.GlobalState, cfg *functi
                        ImageUri: aws.String(cfg.tag),
                },
                PackageType: aws.String(lambda.PackageTypeImage),
+               Architectures: []*string{
+                       aws.String("arm64"),
+               },
        }
        if cfg.memory != 0 {
                args.MemorySize = &cfg.memory

After creating the lambda function this way, it successfully launches ARM64 containers.

  1. Requires a newer version of aws-lambda-go
  2. Currently, there is no Go API to "update" an existing lambda function to use a different architecture.