How to find out current region with AWS Lambda

0 votes

I have a AWS Lambda function written in Java. I want to know if there is a way to find out the AWS region I am currently using through this Lambda function. 

Note: Tried Regions.getCurrentRegion(). It returns null from within an AWS Lambda function.

Dec 20, 2018 in AWS by datageek
• 3,090 points
4,592 views

1 answer to this question.

0 votes

You can read the AWS_DEFAULT_REGION environment variable and use the Regions.fromNamefunction to parse that into a useable region. The advantage of this is you can use it outside your handler function.

Regions.fromName(System.getenv("AWS_DEFAULT_REGION"))
answered Dec 20, 2018 by Archana
• 5,640 points

Related Questions In AWS

+1 vote
1 answer
0 votes
1 answer

How to create a Lambda function with AWS CLI?

Hi@akhtar, To create a function, you need a ...READ MORE

answered Nov 5, 2020 in AWS by MD
• 95,460 points
1,233 views
0 votes
1 answer
0 votes
1 answer

How to link AWS Lambda function to Amazon CloudWatch ?

In order to create Log Group and ...READ MORE

answered Jul 20, 2018 in AWS by datageek
• 2,540 points
1,552 views
0 votes
1 answer
0 votes
1 answer
+2 votes
3 answers
0 votes
1 answer

How to get aws lambda response as an HTML page

Store the HTML markup in a variable and return ...READ MORE

answered Dec 4, 2018 in AWS by Archana
• 5,640 points
1,854 views
0 votes
1 answer

How to invoke the AWS lambda function from Java code

There are 2 methods in this class which should ...READ MORE

answered Feb 19, 2019 in AWS by Archana
• 5,640 points
6,021 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP