Skip to content
Snippets Groups Projects
Unverified Commit bea5f1d2 authored by Ryan Scott Brown's avatar Ryan Scott Brown Committed by GitHub
Browse files

fix: Silence home directory warning in Lambda Extensions (#1344)

* fix: Silence home directory warning in Lambda Extensions

This PR follows on to https://github.com/awslabs/smithy-rs/pull/893 which added
LAMBDA_TASK_ROOT check. When running as a [Lambda Extension][ext]
the environment variable for TASK_ROOT is redacted, so it is not
reliable for testing whether you are in Lambda.

Related commit: fbb4bc

[ext]: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html



* update changelog

* fixup: use AWS_LAMBDA_FUNCTION_NAME which is available in both environments

* Update CHANGELOG.next.toml

* Fix failing unit test

Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>
parent b43dc6df
No related branches found
No related tags found
No related merge requests found
......@@ -34,3 +34,9 @@ message = "Upgrade to Smithy 1.21.0"
references = ["smithy-rs#1330"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "jdisanti"
[[aws-sdk-rust]]
message = "Suppress irrelevant `$HOME` expansion warning when running in a Lambda Extension"
references = ["smithy-rs#1344"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
author = "ryansb"
......@@ -183,8 +183,8 @@ fn expand_home(
/// [Lambdas set many environment variables](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime)
/// that we can check.
fn check_is_likely_running_on_a_lambda(environment: &aws_types::os_shim_internal::Env) -> bool {
// LAMBDA_TASK_ROOT – The path to your Lambda function code.
environment.get("LAMBDA_TASK_ROOT").is_ok()
// AWS_LAMBDA_FUNCTION_NAME – The name of the running Lambda function. Available both in Functions and Extensions
environment.get("AWS_LAMBDA_FUNCTION_NAME").is_ok()
}
#[cfg(test)]
......@@ -261,7 +261,7 @@ mod tests {
#[traced_test]
#[test]
fn load_config_file_should_not_emit_warning_on_lambda() {
let env = Env::from_slice(&[("LAMBDA_TASK_ROOT", "/")]);
let env = Env::from_slice(&[("AWS_LAMBDA_FUNCTION_NAME", "someName")]);
let fs = Fs::from_slice(&[]);
let _src = load_config_file(FileKind::Config, &None, &fs, &env).now_or_never();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment