'Using a "password" that effectively starts a lambda function that triggers an ec2 instance

So I have a lambda function that triggers an amazon ec2 instance and thanks to the api gateway I was able to create a URL for the lambda function. How it works is that you enter the URL and the URL activates the lambda function and starts the amazon ec2 instance. Now what I want to do is to have a "password", (or a secret), that is used to activate the lambda function and THEN start the ec2 instance. I have researched many possible solutions for this but I could not come across any.



Solution 1:[1]

You can pass parameters in the URL, which can be read by the API Gateway function.

You can then add logic to the function to verify the 'password' before starting the Amazon EC2 instance. This could be as simple as verifying that a specific password was provided, or it could perform more complex activities such as checking a database and decrypting an encoded password. It is up to you to write that code.

For an example, see: Pass API Gateway REST API parameters to a Lambda function or HTTP endpoint

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John Rotenstein