I have a function that tries to call another through ARN, however, when it is executed it returns a 502 error, I have checked the role's permissions and they are ok, and the VPC accepts internal traffic.
As an additional piece of information, if I run the program locally from my machine it works, it only fails when I upload it to AWS and run it from there.
ParentLambda:
try:
token = event.get("pathParameters", {}).get("token")
lambda_client = boto3.client('lambda')
payload = {
"token": token
}
res = lambda_client.invoke(
FunctionName='arn:aws:lambda:...........',
InvocationType='RequestResponse',
Payload=json.dumps(payload)
)
res = json.loads(res['Payload'].read())
response = {
"statusCode": 200,
"body": res
}
except Exception as e:
response = {
"statusCode": 500,
"body": str(e)
}
ChildLambda:
try:
token = event['token']
secret = .......................
payload = jwt.decode(token, secret, algorithms=['HS256'])
user = {
"key":"value",
}
response = {
"statusCode": 200,
"body": user
}
except Exception as e:
response = {
"statusCode": 500,
"body": str(e)
}