Skip to content

How to invoke lambda functions? #9

@stephan-nordnes-eriksen

Description

I am struggling to actually invoke a function with AWS.lambda.invoke()

Can you perhaps provide a full example?

Using the example code, I have tried all permutations of the following:

Lambda setup

let lambda = new aws.Lambda({region: 'us-east-1', endpoint: 'http://localhost:3000/proxy' })
let lambda = new aws.Lambda({region: 'us-east-1', endpoint: 'http://localhost:3000' })

Invocation type

InvocationType:  undefined
InvocationType:  "Event"
InvocationType:  "RequestResponse"

Payload

Payload: '{}'
Payload: '{ "name" : "Alex" }'

Lambda invoke

lambda.invoke({
				FunctionName: 'hello',
				InvocationType: invocationType,
				Payload: payload
			}, (err, data) => {/**/})

lambda.invoke({
				FunctionName: 'serverless-offline-direct-lambda-example-dev-hello_proxy',
				InvocationType: invocationType,
				Payload: payload
			}, (err, data) => {/**/})
lambda.invoke({
				FunctionName: 'serverless-offline-direct-lambda-example-dev-hello',
				InvocationType: invocationType,
				Payload: payload
			}, (err, data) => {/**/})
lambda.invoke({
				FunctionName: '/proxy/serverless-offline-direct-lambda-example-dev-hello',
				InvocationType: invocationType,
				Payload: payload
			}, (err, data) => {/**/})
lambda.invoke({
				FunctionName: 'proxy/serverless-offline-direct-lambda-example-dev-hello',
				Payload: '{}'
			}, (err, data) => {/**/})

They all say Unsupported Media Type

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions