Skip to content

Instantly share code, notes, and snippets.

@elect86
Created June 15, 2022 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elect86/178e4cdec420a937a9be42981b3cf041 to your computer and use it in GitHub Desktop.
Save elect86/178e4cdec420a937a9be42981b3cf041 to your computer and use it in GitHub Desktop.
fun main() {
rootModule {
"main".tf { this:TfFile
tls {
proxy {
url = "https://corporate.proxy.service"
from_env = true
}
}
cert_request {
private_key_pem = ""
}
val a by cert_request {
private_key_pem = ""
}
}
}.generate(File("terraform"))
}
fun TfFile.cert_request(id: String = "", configure: CertRequest.() -> Unit): CertRequest {
val element = CertRequest("id").apply(configure)
add(element)
return element
}
operator fun CertRequest.provideDelegate(ref: Any?, prop: KProperty<*>): CertRequest= this.apply {
this.tf_id = prop.name
}
operator fun CertRequest.getValue(ref: Any?, prop: KProperty<*>): CertRequest = this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment