Created
March 3, 2021 17:25
-
-
Save yeisoncruz16/0027c654d8c4213b77325b5407c0dbff to your computer and use it in GitHub Desktop.
Simple lambda function to get Current IP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let response; | |
exports.lambdaHandler = async (event, context) => { | |
try { | |
const ret = await axios(url); | |
response = { | |
'statusCode': 200, | |
'body': JSON.stringify({ | |
location: ret.data.trim() | |
}) | |
} | |
} catch (err) { | |
console.log(err); | |
return err; | |
} | |
return response | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also you can use the AWS endpoint
http://checkip.amazonaws.com/