Monday, February 26, 2018

What is AWS Lambda ?

What is AWS LAMBDA?



AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume - there is no charge when your code is not running.

With Lambda, you can run code for virtually any type of application or backend service - all with zero administration. Just upload your code and Lambda takes care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app.




WHY LAMBDA?

NO SERVERS TO MANAGE

AWS Lambda automatically runs your code without requiring you to provision or manage servers. Just write the code and upload it to Lambda.



CONTINUOUS SCALING
AWS Lambda automatically scales your application by running code in response to each trigger. Your code runs in parallel and processes each trigger individually, scaling precisely with the size of the workload.



SUBSECOND METERING
With AWS Lambda, you are charged for every 100ms your code executes and the number of times your code is triggered. You don't pay anything when your code isn't running.


 Lambda Function for Start Ec2 Instance

import boto3
# Enter the region your instances are in. Include only the region without specifying Availability Zone; 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)



Please find the Details Step By Step for Ec2 Start Stop Through lambda https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-cloudwatch/








Lambda Function for Stop Ec2 Instance


 boto3
# Enter the region your instances are in. Include only the region without specifying Availability Zone; 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.stop_instances(InstanceIds=instances)
    print 'stopped your instances: ' + str(instances)

5 comments:

  1. It has fully emerged to crown Singapore's southern shores and undoubtedly placed her on the global map of residential landmarks. I still scored the more points than I ever have in a season for GS. I think you would be hard pressed to find somebody with the same consistency I have had over the years so I am happy with that.
    data science course malaysia

    ReplyDelete
  2. To be the best candidate of robotics, you need to enroll in a recognized Robotics training and certification imparting institute. machine learning courses in hyderabad

    ReplyDelete

  3. Infycle Technologies offers the best Python training in Chennai for tech professionals and freshers with New year offers. In addition to the Python Training Course, Infycle also offers other technical courses such as Data Science, Oracle, Java, Power BI, Digital Marketing,
    Infycle Technologies offers the best Python training in Chennai for tech professionals and freshers with New year offers. In addition to the Python Training Course, Infycle also offers other technical courses such as Data Science, Oracle, Java, Power BI, Digital Marketing, Big Data, etc., which will be trained with complete practical classes. Dial 7504633633 to get more info and a free demo.
    Big Data, etc., which will be trained with complete practical classes. Dial 7504633633 to get more info and a free demo.

    ReplyDelete

Wireless Security Configuration: Protect Your Network Now!

Introduction: In today’s connected world, wireless networks are as common as smartphones, and they’re often the gateway to our personal, pr...