diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/DevOps.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/DevOps.kt index dec4f92..e9bf39f 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/DevOps.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/DevOps.kt @@ -4,9 +4,12 @@ import org.domaindrivenarchitecture.provs.core.Prov import org.domaindrivenarchitecture.provs.core.ProvResult import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createDirs import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.dirExists +import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createFile + fun Prov.installDevOps() = def { installTerraform() + installAwsCredentials("", "") // TODO: get credentials from gopass } fun Prov.installTerraform(): ProvResult = def { @@ -23,3 +26,28 @@ fun Prov.installTerraform(): ProvResult = def { 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() +} \ No newline at end of file