top of page

Debugging Lambda in Cloud9 (Passing Arguments via payload)

Jul 20
1 min read

I could never quite get on with the AWS Toolkit, so I'd turned it off and developed using the tools that appear on the right side of the Cloud9 screen — but it seems using the toolkit has finally become mandatory, and I can no longer turn it off. I was debugging on Cloud9, and got stuck right at the point of passing arguments to the program.

Development environment

Cloud9

Instance type: t2.micro

EBS: 30GB (gp2)

Development language: python3.9

How to pass arguments to a program on Cloud9

Code to run: helloworld/lambda_function.py

import json

def lambda_handler(event, context):
    print(event)
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

Write the code so that print(event) displays the arguments

Create a file in the project folder that defines the arguments. The file name can be anything you'll recognise.

Here it's "helloworld/lambda-payloads.json".

In the file, write the values to pass as arguments in JSON.

Click the up/down arrow area at the top of Cloud9 and choose "Edit Launch Configuration"

In the launch.json that appears, write the path of the file you just created in the payload section for the target project, and save launch.json

After that, run "Run" at the top of the Cloud9 screen, and if the arguments are displayed in the console at the bottom of the screen, it worked.

With this, one more piece is in place for developing on Cloud9.

 
 
 

Comments


© Copyright ROBIN planning LLC.

​Privacy Policy

​Disclaimer

bottom of page