Search code examples
pythonamazon-web-serviceschalice

missing public key file in chalice


I am working with Chalice Chalice (to write python rest api) and cashfree sdk Cashfree SDK (to transfer money).

I have a public_key.pem file which helps in maintaining a dynamic IP DYnamic Link Info.

I have been able to run this code in local ... But when I deploy this ..it says cannot find key.pem. I am unable to understand how should I pass my key file to it.

@app.route('/payment', methods=[ 'POST'])
def payment():
    json_input = app.current_request.json_body
    transferID = json_input["transferID"]
    amt = json_input["amt"]
    try:
        Payouts.init(clientId, 
        clientSecret, 
        env , 
        public_key_path="key.pem")
        try:
            request_transfer_response = Transfers.request_transfer(beneId="JOHN18012",
                                                       transferId=transferID,
                                                       transferMode="upi",
                                                       amount=amt)
        except Exception as e:
            return {"error1":str(e)}
    except Exception as e:
        return {"error2":str(e)}


    return json.loads(request_transfer_response.content)

Solution

  • So, as I was not able to pass the key file with chalice deploy. I added the key file to S3 bucket and called it in runtime to successfully execute my code.