Skip to content

Commit 9e015c7

Browse files
authored
fix: set metadata from AWS_EXECUTION_ENV (#299)
1 parent 7f4e0ff commit 9e015c7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

aws-runtime/aws-core/common/src/aws/sdk/kotlin/runtime/AwsSdkSetting.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,10 @@ public sealed class AwsSdkSetting<T> (
5151
* Configure the default region.
5252
*/
5353
public object AwsRegion : AwsSdkSetting<String>("AWS_REGION", "aws.region")
54+
55+
/**
56+
* The execution environment of the SDK user. This is automatically set in certain environments by the underlying AWS service.
57+
* For example, AWS Lambda will automatically specify a runtime indicating that the SDK is being used within Lambda.
58+
*/
59+
public object AwsExecutionEnv : AwsSdkSetting<String>("AWS_EXECUTION_ENV", "aws.executionEnvironment")
5460
}

aws-runtime/protocols/http/common/src/aws/sdk/kotlin/runtime/http/AwsUserAgentMetadata.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package aws.sdk.kotlin.runtime.http
77

8+
import aws.sdk.kotlin.runtime.AwsSdkSetting
89
import aws.smithy.kotlin.runtime.util.OsFamily
910
import aws.smithy.kotlin.runtime.util.Platform
1011

@@ -133,8 +134,8 @@ public data class ExecutionEnvMetadata(val name: String) {
133134
}
134135

135136
private fun detectExecEnv(): ExecutionEnvMetadata? =
136-
Platform.getenv("AWS_LAMBDA_FUNCTION_NAME")?.let {
137-
ExecutionEnvMetadata("lambda")
137+
Platform.getenv(AwsSdkSetting.AwsExecutionEnv.environmentVariable)?.let {
138+
ExecutionEnvMetadata(it)
138139
}
139140

140141
// ua-value = token

0 commit comments

Comments
 (0)