How can one determine the current region within an AWS Lambda function?
You can read the AWS_REGION
environment variable and use the Regions.fromName
function to parse that into a useable region.
Regions.fromName(System.getenv("AWS_REGION"))
The advantage of this over the ARN parsing approach is that you do not need a Context object which means you can use it outside of your handler function.
Source: AWS's Lambda environment variables docs.
All Lambda containers has environment variables set $AWS_REGION
From Java Code in Lambda.You can access it as below
System.getenv("AWS_REGION")