The AWS Graviton ARM based compute resources are in most cases faster than intel/amd resources..
awslambda.NewDockerImageFunction(stack,
aws.String("RegisterHandlerArm"),
&awslambda.DockerImageFunctionProps{
Architecture: awslambda.Architecture_ARM_64(),
FunctionName: aws.String("hellodockerarm"),
MemorySize: aws.Float64(1024),
Timeout: awscdk.Duration_Seconds(aws.Float64(300)),
Code: awslambda.DockerImageCode_FromImageAsset(&dockerfile, &awslambda.AssetImageCodeProps{}),
})
The CDK supports the new Architecture type and the container deployment.
The architecture which Lambda runs in the configured here:
Architecture: awslambda.Architecture_ARM_64(),
And the deployment type is just defined here:
Code:awslambda.DockerImageCode_FromImageAsset(&dockerfile, &awslambda.AssetImageCodeProps{}),
You only have to change one line in the Dockerfile:
RUN env GOOS=linux GOARCH=arm64 go build -o=/main
This tells GO to build for the arm/Graviton architecture.