Some examples in internet have AWS_DEFAULT_REGION
env variable set but some others AWS_REGION
. What is the difference? Which services use one or another?
PDFRSS. You can use environment variables to adjust your function's behavior without updating code. An environment variable is a pair of strings that is stored in a function's version-specific configuration.
To get the AWS Region where your Lambda Function is running you will need to import the os module. Then from the os module, you need to get the value of AWS_REGION from the environ mapping variable. This will return the AWS Region where the Lambda Function is running.
They are not the same: one works in some situations and the other works in other situations.
e.g. I just learned that AWS_DEFAULT_REGION
does not work with the AWS Java API library. See Force AWS library to obtain region from environment inside docker cluster
cf. 44151982, 36354423, Github aws/aws-sdk-go#2103
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With