No Build Tool
You don’t need a build tool to run KloudFormation. You can install Kloudformation on mac / linux by opening a terminal and running the following command
$ curl -sSL https://install.kloudformation.hexlabs.io | bash
Then this to see how it works:
$ kloudformation help
For More Info on the Command Line Interface See Command Line
Code Completion in IntelliJ without Maven / Gradle
The first time you run the KloudFormation script above it will download jars into a directory named kloudformation
wherever you ran the script.
You can then open the project in IntelliJ as follows:
-
After installing KloudFormation (Above), In a clean directory Run:
$ mkdir stack && kloudformation init -stack-file stack/Stack.kt
-
Transpile the generated Stack file (This will download all jars into a kloudformation directory):
$ kloudformation -stack-file stack/Stack.kt
-
Open the current directory in IntelliJ
-
In IntelliJ, right click on the
stack
folder and selectMark Directory As > Sources Root
-
In IntelliJ, right click on
kloudformation/kloudformation-x.x.xxx.jar
and selectAdd as Library...
and click OK. -
Open stack/Stack.kt and start writting your stack.
Manually
Alternatively if gradle, maven or the above options don’t suit you can try running manually with the uber jar.
You can create a template from anywhere as long as you have kotlinc and java available.
Make sure you build a stack by implementing StackBuilder
import io.kloudformation.model.KloudFormationTemplate import io.kloudformation.toYaml //sampleStart import io.kloudformation.KloudFormation import io.kloudformation.StackBuilder class Stack: StackBuilder { override fun KloudFormation.create() { } } //sampleEnd fun main(){ println(KloudFormationTemplate.create { Stack().run { create() } }.toYaml()) }
Download the latest KloudFormation jar from bintray.
Make sure to download the uber jar from Bintray
The steps required to generate your template are as follows:
- Place the file containing your Stack class into the same directory as the KloudFormation uber jar.
- Rename the uber jar to kloudformation.jar
- Compile your stack class using the following command:
kotlinc -cp kloudformation.jar <your-stack-file>.kt -include-runtime -d stack.jar
- Run the
StackBuilder
to generate your stack template:java -classpath stack.jar:kloudformation.jar io.kloudformation.StackBuilderKt Stack template.yml
Your template will be in a file called template.yml