0

I have Python code to stop EC2 instances in AWS using lambda function from this link. This Python 2.7 code is working fine when I am using with the Lambda function.

The lambda function to stop instances also can be executed from the API endpoint.

Now how can I stop instances by providing an instance id with the API endpoint in browser instead to provide in the Python code?

Can anyone help me on this?

Martin Evans
  • 45,791
  • 17
  • 81
  • 97
  • You question is very unclear, but if I understand correctly you just want to pass a parameter to a lambda function, so you question might be a duplicate of [this one](http://stackoverflow.com/questions/31329958/how-to-pass-a-querystring-or-route-parameter-to-aws-lambda-from-amazon-api-gatew) – Nader Ghanbari Mar 24 '17 at 21:06

1 Answers1

0

You can pass the instance id in the payload (assuming you are using POST) from API gateway to Lambda. Read that payload in Lambda, parse the instance id and use that. That's it.

See this for more details http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started.html#getting-started-new-post

If you are using GET then here are the details http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started.html#getting-started-new-get

Arafat Nalkhande
  • 11,078
  • 9
  • 39
  • 63