Simple implementation for AWS Lambda Function with Kotlin with Blue/Green deployment using AWS CodeDeploy.
Currently AWS Lambda Java runtime supports Java 11 (amazon-corretto-11)
git clone https://github.com/kopkunka55/aws-lambda-kotlin-ddb-stream-consumer
cd aws-lambda-kotlin-ddb-stream-consumer
Add the following gradle script to generate an executable .jar file
tasks.jar {
manifest {
attributes["Main-Class"] = "MainKt"
}
configurations["compileClasspath"].forEach { file: File ->
from(zipTree(file.absoluteFile))
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
Execute the following command to build Kotlin function, or just run [Gradle] -> [Tasks] -> [build]
./gradlew build
Once Gradle build is done. JAR artifact file will be available at
build/libs/aws-lambda-kotlin-1.0-SNAPSHOT.jar
. The file can be referenced
from Terraform to deploy AWS Lambda function.
Initialize terraform modules
cd aws
terraform init
check what terraform create or update
terraform plan
deploy to remote resources
terraform apply
Terraform automatically maps the current Lambda version to the alias defined at initial deployment step, and then traffic balance between current and previous version will be shifted gradually by AWS CodeDeploy.
./gradlew build
terraform apply