Skip to content

Plugin Overview

Vladislav Tankov edited this page Oct 19, 2019 · 14 revisions

Kotless gradle plugin is a key component in Kotless architecture. It tightens up the abstract representation of Serverless application and its actual deployment.

The plugin defines several tasks to deploy Kotless-based application:

  • generate — generates Terraform code from Kotlin code written using Kotless DSL;
  • plan — executes plan Terraform operation on generated Terraform code;
  • deploy — executes apply Terraform operation on generated Terraform code;
  • destroy — executes destroy Terraform operation, if enabled in extensions.

Note that actual lambdas jars are prepared using shadowJar plugin.

Furthermore, Kotless gradle plugin defines certain configurations of Kotless-based application deployment.

Following configurations are available via the plugin:

  • Kotless config — configuration of Terraform, its cloud provider, kotless-used buckets, and global optimizations;
  • Web Application configs — configuration of lambdas used in a specific web application, its alias, and deployment parameters;
  • Extensions configs — configuration that defines different extensions for Kotless pipeline. For example, it may enable destroy task or add user's Terraform files to deployment code.

Here is a simple snippet of the whole configuration:

config {
    //see details in a Kotless Configuration docs
    bucket = "kotless.s3.example.com"
    prefix = "dev"

    workDirectory = file("src/main/static")
    
    terraform {
        profile = "example-profile"
        region = "us-east-1"
    }
    
    optimization {
        mergeLambda = MergeLambda.All
    }
    
    //see details in a WebApp Configuration docs
    webapp {
        packages = setOf("org.example.kotless")
        route53 = Route53("kotless", "example.com")
        lambda {
            timeoutSec = 300
            memoryMb = 512
        }
    }
}