added awsCredentials function
This commit is contained in:
parent
c607817fbc
commit
eb0547b51d
1 changed files with 28 additions and 0 deletions
|
@ -4,9 +4,12 @@ import org.domaindrivenarchitecture.provs.core.Prov
|
||||||
import org.domaindrivenarchitecture.provs.core.ProvResult
|
import org.domaindrivenarchitecture.provs.core.ProvResult
|
||||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createDirs
|
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createDirs
|
||||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.dirExists
|
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.dirExists
|
||||||
|
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createFile
|
||||||
|
|
||||||
|
|
||||||
fun Prov.installDevOps() = def {
|
fun Prov.installDevOps() = def {
|
||||||
installTerraform()
|
installTerraform()
|
||||||
|
installAwsCredentials("", "") // TODO: get credentials from gopass
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Prov.installTerraform(): ProvResult = def {
|
fun Prov.installTerraform(): ProvResult = def {
|
||||||
|
@ -23,3 +26,28 @@ fun Prov.installTerraform(): ProvResult = def {
|
||||||
cmd ("tfenv use latest:^0.13", sudo = true)
|
cmd ("tfenv use latest:^0.13", sudo = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Prov.installAwsCredentials(id:String, key:String): ProvResult = def {
|
||||||
|
val dir = "~/.aws"
|
||||||
|
|
||||||
|
if(!dirExists(dir)) {
|
||||||
|
createDirs(dir)
|
||||||
|
createFile("~/.aws/config", awsConfig())
|
||||||
|
createFile("~/.aws/credentials", awsCredentials(id, key))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun awsConfig(): String {
|
||||||
|
return """
|
||||||
|
[default]
|
||||||
|
region = eu-central-1
|
||||||
|
output = json
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun awsCredentials(id:String, key:String): String {
|
||||||
|
return """
|
||||||
|
[default]
|
||||||
|
aws_access_key_id = $id
|
||||||
|
aws_secret_access_key = $key
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
Loading…
Reference in a new issue