Skip to content

Plugin Overview

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

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

Plugin defines few tasks to deploy Kotless-based application:

  • generate — task generates terraform code from Kotlin code written using Kotless DSL.
  • plan — executes plan terraform operation on a 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 a part of configurations of a Kotless-based application deployment.

Following configurations are available via a plugin:

  • Kotless config — configuration of terraform, it's cloud provider, kotless used buckets and global optimizations
  • WebApp configs — configuration of lambdas used in specific web application, it's 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 the 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
        }
    }
}