AWS Lambda HTTP 503 when opening amazon urls

60 views Asked by At

Hello I developed an AWS Lambda which makes an http request to amazon url to get the web page content. The problem I have regards the HTTP 503 error I get every time I run the lambda. Running the code locally it works fine but on AWS it doesn't.

I am using Python 3.7 and urllib module

Below the source code

import urllib.request

url = 'https://www.amazon.it/dp/B0786QNS9B'
reqq = urllib.request.Request(url=url, headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'})
reddit_file = urllib.request.urlopen(reqq)

I changed several times the User-agent value but it doesn't work.

I was wondering if the problem could be related to the IP address used by my AWS account when I run the lambda, I checked what's the IP used every time and I see it's always the same, so basically it's a static ip address.

I'm not using the API Gateway service, just the lambda only.

Is it possible to use a different IP address for each run of the lambda function? Will this solve my issue?

Thanks

0

There are 0 answers