I'd like to give my client a (password protected) link, such that opening it will start an AWS instance. Is it possible to do it using AWS-Lambda without constantly running another instance?
Yes, for example here is a function that will start an instance:
import boto3
# Enter the region your instances are in, e.g. 'us-east-1'
region = 'XX-XXXXX-X'
# Enter your instances here: ex. ['X-XXXXXXXX', 'X-XXXXXXXX']
instances = ['X-XXXXXXXX']
def lambda_handler(event, context):
ec2 = boto3.client('ec2', region_name=region)
ec2.start_instances(InstanceIds=instances)
print 'started your instances: ' + str(instances)
once you create that Lambda function (similar to the above - from the link below), you can define an AWS API endpoint in AWS and have it call the lambda function.
This link may help with some of what you want to do (the lambda functions).
https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-cloudwatch/
Yes you can. You should use a combination of AWS lambda and AWS api gateway. AWS api gateway (gw) takes care of exposing a http url and you can optionally let AWS api gateway handle the authentication using a custom authorizer.
Api gateway can trigger an AWS lambda function which will then run the actual code to start the instance.
Additional notes:
I hope this helps.
G.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With