My application is to use an link(url) to invoke lambda function ,then I want to know public IP of lambda and get page source. How could I get lambda public IP by using python? Thanks a lot.
No, Lambda functions do not get a public IP, regardless of the auto-assign IPv4 address setting. They cannot have public IPs. To reach the internet, they must route through a NAT (which routes to an IGW).
AWS Lambda does not include Pandas/NumPy Python libraries by default. How use Pandas and NumPy with Lambda functions?
You can curl to checkip.amazonaws.com
to get the public IP.
import requests
requests.get('http://checkip.amazonaws.com').text.rstrip()
Output:
52.x.147.64
I would suggest:
from botocore.vendored import requests
requests.get('http://checkip.amazonaws.com').text.rstrip()
inside your lambda
function.
Otherwise you may get an error that says that lambda cannot find requests
unless you created your lambda from a .zip file that includes requests
installed via pip
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