hostinfo: detect AWS Lambda as a container.
AWS Lambda uses Docker containers but does not
have the string "docker" in its /proc/1/cgroup.
Infer AWS Lambda via the environment variables
it sets.
@@ -62,6 +62,9 @@ func osVersionLinux() string {
if inKnative() {
attrBuf.WriteString("; env=kn")
}
+ if inAwsLambda() {
+ attrBuf.WriteString("; env=lm")
+ }
attr := attrBuf.String()
id := m["ID"]
@@ -121,3 +124,14 @@ func inKnative() bool {
}
return false
}
+
+func inAwsLambda() bool {
+ // https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html
+ if os.Getenv("AWS_LAMBDA_FUNCTION_NAME") != "" &&
+ os.Getenv("AWS_LAMBDA_FUNCTION_VERSION") != "" &&
+ os.Getenv("AWS_LAMBDA_INITIALIZATION_TYPE") != "" &&
+ os.Getenv("AWS_LAMBDA_RUNTIME_API") != "" {
+ return true
+ }
+ return false
+}
