Parent Lambda return error 502 when call child Lambda

0

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)
    }
Zerox
asked 7 months ago184 views
1 Answer
0

You could troubleshoot using the following documentation: https://repost.aws/knowledge-center/lambda-troubleshoot-invoke-error-502-500

AWS
vtjean
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions