Home > Back-end >  Invoke a lambda from VSCode python
Invoke a lambda from VSCode python

Time:02-11

could not find any answer on this.

All the tutorials mention how to use AWS toolkit or how to locally develop and test your lambda on VSCode. That's not what I would like, I already have a lambda, and I would just like to invoke it.

To call a s3 or Dynamo DB, I can just run

dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table(table_name)
scan_kwargs = {
    'FilterExpression': Key(my_key).eq(key_equal)
}
response = table.scan(**scan_kwargs)
data = response['Items']

What is the equivalent for invoking the lambda?

CodePudding user response:

Try:

lambda_client = boto3.client('lambda', region_name='')

lambda_client.invoke(FunctionName='', InvocationType='', Payload='')

Where the empty strings can be replaced with your information.

See: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#client

  • Related