JetBrains / kotless

Kotlin Serverless Framework
Apache License 2.0
1.15k stars 57 forks source link

spring - application.yaml #125

Open mamaorha opened 1 year ago

mamaorha commented 1 year ago

it seems like the application.yaml under resources is ignored when deploying (it does work when running local).

omnibrain commented 1 year ago

I'm facing the same problem. Any documentation on how to configure spring or define some env variables would be very helpful

mamaorha commented 1 year ago

i ended up using env variables via the gradle config and adjust them on runtime due to the fact the teraform wasnt able to parse complex env names.

part i added to build gradle:

kotless {
    webapp {
        lambda {
            environment = hashMapOf(
                "MYSQL_PASS" to "MY_VALUE"
            )
        }
    }
}

later on my main class i reassigned them via:

@SpringBootApplication
open class Application : Kotless() {
    init {
        System.setProperty("spring.datasource.password", System.getenv()["MYSQL_PASS"])
    }

    override val bootKlass: KClass<*> = this::class
}

small note that secrets should not be under the "gradle" file as you probably want to push the file to your git. instead you can & should use some secret manager like aws have to offer.