Configuration

Configuration of plugin consists of two main parts - Kotless configuration and per-webapp configuration.We will take a look at them one by one.

Kotless Configuration

Kotless configuration of Gradle plugin consists of a few globally applied parts:

Here is a simple snippet of the whole configuration:

config {
    bucket = "kotless.s3.example.com"
    prefix = "dev"

    workDirectory = file("src/main/static")

    terraform {
        profile = "example-profile"
        region = "us-east-1"
    }

    optimization {
        mergeLambda = MergeLambda.All
    }
}

We will take a look at parts of this configuration one by one.

Terraform configuration

In a `terraform` configuration you can set up version of Terraform used, it's AWS provider and bucket for `tfstate`.

You will need to set up `region` and `profile` -- region for deployment and local profile used for it accordingly.

Note, that Kotless supports deployment to any region, but requires certificate to be created in us-east-1. It is AWS limitation and cannot be fixed in Kotless.

Here is the simplest possible snippet with a setup of terraform configuration:

terraform {
    //Will use for terraform state buckets used by kotless service configuration
    //version of terraform and aws provider will be default
    profile = "example-profile"
    region = "us-east-1"
}

Note, that needed version of terraform will be downloaded automatically.

Kotless service configuration

Kotless service configuration is a set of directories, S3 bucket and few values used by Kotless to deploy your application.

You will need to set up `bucket` -- it is a name of bucket that Kotless will use to store all files. For example, Kotless will store there packed jars and static files.

You can set `resource-prefix` variable -- it is a prefix with which all created in a cloud resources will be prepended. `resource-prefix` can be used to deploy few environments of one application.

Probably, you will need to change `workDirectory` variable -- it is a folder, that Kotless will use as a root to resolve all static route files.

Here is a simple snippet with a setup of service configuration:

config {
    bucket = "kotless.s3.example.com"
    prefix = "dev"

    workDirectory = file("src/main/static")
}

Note, that `bucket` value will be used for terraform state, if it is not set explicitly in a terraform configuration.

Optimization configuration

We are doing our best to make Kotless-based lambdas as fast as possible.

There are plenty of optimizations that are embedded in a Kotless synthesizer and runtime. Some of them can be configured to align with you needs.

Lambda Merge Optimization

Optimization defines if different lambdas should be merged into one and when.

Basically, lambda serving few endpoints is more likely to be warm.

There are 3 levels of merge optimization:

Here is a simple snipped of optimization configuration:

optimization {
    mergeLambda = MergeLambda.All
}

Lambda AutoWarming Optimization

This optimization sets up a timer that will autowarm lambda, by default each 5 minutes. Such an optimization makes cold start less frequent.

Each timer event executes warming sequence. This sequence triggers `LambdaWarming` objects and is described in a Lifecycle API section.

optimization {
    //default config
    autowarm = Autowarm(enable = true, minutes = 5)
}

Kotless lambdas can be autowarmed. It means, that some scheduler will periodically (by default, each 5 minutes) call lambda to be sure, that it will not be displaced from hot pool of cloud provider.

WebApp Configuration

WebApp configuration in a Kotless gradle plugin defines project-specific deployment configuration.

In WebApp configuration you must set `packages` variable -- it is a set of packages under which Kotless will look for usages of DSL. All other usages will be ignored.

You may set `route53` variable -- it defines a Route53 alias for your application. You will need an ACM certificate in us-east-1 to create it.

It is possible to configure lambda parameters -- you should use `lambda` function for it. You can set timeout of lambda, memory in MB and autowarm configuration.

Here is the simple snippet of the webapp configuration:

webapp {
    packages = setOf("org.example.kotless")
    route53 = Route53("kotless", "example.com")
    lambda {
        timeoutSec = 300
        memoryMb = 512
    }
}