All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.wisp.aws.environment.AwsEnvironment.kt Maven / Gradle / Ivy

There is a newer version: 2024.12.12.153725-b454031
Show newest version
package wisp.aws.environment

import wisp.deployment.EnvironmentVariableLoader

/** [AwsEnvironment] pulls region and account information from installed
 * environment variables
 *
 * Note: Because of different package names for AWS1 vs AWS2 sdks, we can't use AWS's Region class.
 */
object AwsEnvironment {

    fun awsRegion(
        environmentVariableLoader: EnvironmentVariableLoader = EnvironmentVariableLoader.real,
        environmentVariables: List = listOf("REGION", "AWS_REGION"),
        defaultAwsRegion: String = "us-west-2"
    ): AwsRegion {
        for (environmentVariable in environmentVariables) {
            val region =
                environmentVariableLoader.getEnvironmentVariableOrDefault(environmentVariable, "")
            if (region.isNotEmpty()) {
                return AwsRegion(region)
            }
        }
        return AwsRegion(defaultAwsRegion)
    }

    fun awsAccountId(
        environmentVariableLoader: EnvironmentVariableLoader = EnvironmentVariableLoader.real,
        environmentVariable: String = "ACCOUNT_ID",
    ): AwsAccountId =
        AwsAccountId(environmentVariableLoader.getEnvironmentVariable(environmentVariable))
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy