-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kotlin language support #557
Comments
👍 from @skinny85 in aws/jsii#3925 |
I'd like to take a stab at contributing Kotlin support along with Gradle build with Kotlin DSL assuming this work hasn't already started. Any pointers other than looking at what was done for Java? |
I’ve written a POC which uses Kotlin language and Gradle Kotlin DSL: https://github.com/digitalsanctum/cdk-kotlin-example. I don’t think it would take much to add support for Kotlin and Gradle but the wiring up of |
Thanks @digitalsanctum! This is awesome. Asked some questions on your commit. Happy to include this as a template for |
Thanks. I've replied to your questions there. The POC was a first step to prove that supporting Kotlin and Gradle wouldn't be a lot of extra effort. I'd like to address #1294 and further simplify the semantics around |
I've started one, roughly tested :P |
@willings this is great! Would love to explore the option of adding this to our official release |
Any news on this? @willings repo looks promising. |
Hi, I'm working on wrapper library of cdk. Now, no documents are available but all source codes are available: This is WIP project, so any issue comment, or contribution is welcome. |
Another approach could be leveraging Kotlin's JS compatibility. JetBrains provides dukat to generate Kotlin JS files from TS definitions. |
Jesus what happened here?? seemed like it was going to happen, but no... ! |
Any updates on this? |
Any updates? |
I have created a cookiecutter template, that I can open source if people are interested (and maybe add it to the CDK templates): This is what the directory structure looks like, it assumed your
plugins {
id "application"
}
def cdkVersion = "1.96.0"
dependencies {
implementation("org.slf4j:slf4j-simple:1.7.30")
// AWS Cloud Development Kit
implementation("software.amazon.awscdk:core:$cdkVersion")
// Respective AWS Construct Libraries
implementation("software.amazon.awscdk:iam:$cdkVersion")
implementation("software.amazon.awscdk:lambda:$cdkVersion")
implementation("software.amazon.awscdk:dynamodb:$cdkVersion")
implementation("software.amazon.awscdk:apigateway:$cdkVersion")
}
application {
mainClassName = 'com.fiserv.services.footie.cdk.app.AppKt'
}
{
"app": "cd ../; ./gradlew -q cdk:run",
"context": {
"branch": "develop",
"env_dev": {
"example": "DEMO ENVIRONMENT VARIABLE"
}
}
} Example stack.kt package com.fiserv.services.footie.cdk.stack
import software.amazon.awscdk.core.*
import software.amazon.awscdk.core.Stack
class ApplicationStack(scope: Construct, id: String, props: StackProps? = null) : Stack(scope, id, props) {
init {
val environment = this.node.tryGetContext("env") as String? ?: "dev"
val branch = this.node.tryGetContext("branch") as String? ?: "develop"
val namespace = "$environment${if (branch == "master") "" else "-$branch"}"
@Suppress("UNCHECKED_CAST")
val settings = this.node.tryGetContext("env_$environment") as Map<String, String>?
?: throw RuntimeException("settings needs to be configured for $environment")
// NOTE: Example of getting a environment config value from the cdk.json
val example = settings.requireNotNull("example")
CfnOutput(
this,
"ExampleOutput",
CfnOutputProps
.builder()
.exportName("example-variable-$namespace")
.value(example)
.description("Example variable you can show or share for this stack: $namespace")
.build()
)
}
private fun Map<String, String>.requireNotNull(name: String) = requireNotNull(this[name]) {
"'$name' needs to be configured in cdk.json"
}
} |
Btw. what @willings is the best I have seen for CDK, I hold AWS takes this on,. |
Yes this is great idea, a fluent Kotlin DSL for CDK would be great |
+1 I just got “done” working on a stack that I’ve been at it for like… 6 months? TS isn’t bad once I got used to it. Kotlin would be nice. Would compile/run times times be relatively slower or faster than TS? Would auto scaling be impacted? |
I agree that TS is not bad alternative, my preference for Kotlin comes from the fact that:
On the last one I think that it would be very interesting if the CDK/TS could run via [https://deno.land/] where there is much better security and sandboxing of JS code. |
Is there any update on this? |
Closing this as a duplicate of aws/jsii#1541 |
|
+1 if you would like to see Kotlin support for the CDK
The text was updated successfully, but these errors were encountered: