shiv455
shiv455

Reputation: 7764

pass array as a key value to Aws Lambda

Im trying to pass below event keys to AWS lambda python function.

Payload='{"OS":"ubuntu","region":"us-east-1","subnetids":"'subnet-123','subnet-456','subnet-789','subnet-101112'","vpcid":"vpc-abcd"}')

facing issue passing subnetids to lambda function as its a list not a single item.

And in actual fucntion not sure how to read this payload as events itself is an array

i can read OS ,region as event["OS"],event["region"] but not sure how to read subnetids as if i try event["subnetids"] its trying to read as single value not as list of subnets

Please suggest!!

Upvotes: 1

Views: 2785

Answers (1)

David
David

Reputation: 11593

Your example isn't proper json. To make it such, you'll need to wrap your subnets in array and change the quoting like:

Payload='{"OS":"ubuntu","region":"us-east-1","subnetids":["subnet-123", "subnet-456","subnet-789","subnet-101112"],"vpcid":"vpc-abcd"}'

Upvotes: 4

Related Questions