aws-cdk-dsl / aws-cdk-kotlin-dsl

Kotlin DSL for AWS CDK
MIT License
32 stars 0 forks source link
aws aws-cdk cloudformation cloudformation-dsl kotlin kotlin-dsl

AWS CDK Kotlin DSL

Kotlin Build Status License: MIT

The DSL wrapper on top of AWS CDK. The DSL is fully compatible with SDK Java implementation, meanwhile improves readability of infrastructure related code.

Why AWS CDK Kotlin DSL?

It is a great concept of infrastructure as code, however the problem is what kind of code should it be?

The idea of Kotlin DSL is to utilize Kotlin's type-safe builder which has been proved as successful in latest Gradle build.gradle practice. The benefit of this way is:

A quick example of constructing stack using Kotlin DSL, we could see the benefit easily.

fun main() {

    app {
        stack("myStackId") {
            function("myFunctionId", functionProps {
                functionName = "myFunction"
                runtime = NODE_J_S810
                memorySize = 128
                handler = "index.handler"
                code = Code.inline("""
                    exports.handler = function(event, context, callback) {
                        callback(null, "Hello, World!");
                    }
                """.trimIndent())
            })
        }
    }.run()
}

Quick Start

(It is not released to mavenCentral or jCenter yet)

Checkout lambda-example under examples for a quick view!

Known issues

License

The AWS CDK Kotlin DSL is distributed under the MIT License.