How to Automatically Stop/Start EC2 instances using AWS Lambda| Cloudwatch Events Scheduler
In this video we have walked through to Start/Stop instance using Lambda function and manage using Cloudwatch Events .
Refer Link : https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-cloudwatch/
Please Find the Scripts
To Create IAM policy using JSON policy editor:-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"ec2:Start*",
"ec2:Stop*"
],
"Resource": "*"
}
]
}
Stop the instances:-
import boto3
region = 'us-west-1'
instances = ['i-12345cb6de4f78g9h', 'i-08ce9b2d7eccf6d26']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.stop_instances(InstanceIds=instances)
print('stopped your instances: ' + str(instances))
Start the instances:-
import boto3
region = 'us-west-1'
instances = ['i-12345cb6de4f78g9h', 'i-08ce9b2d7eccf6d26']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.start_instances(InstanceIds=instances)
print('started your instances: ' + str(instances))
Видео How to Automatically Stop/Start EC2 instances using AWS Lambda| Cloudwatch Events Scheduler канала Tech Nest
Refer Link : https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-cloudwatch/
Please Find the Scripts
To Create IAM policy using JSON policy editor:-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"ec2:Start*",
"ec2:Stop*"
],
"Resource": "*"
}
]
}
Stop the instances:-
import boto3
region = 'us-west-1'
instances = ['i-12345cb6de4f78g9h', 'i-08ce9b2d7eccf6d26']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.stop_instances(InstanceIds=instances)
print('stopped your instances: ' + str(instances))
Start the instances:-
import boto3
region = 'us-west-1'
instances = ['i-12345cb6de4f78g9h', 'i-08ce9b2d7eccf6d26']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.start_instances(InstanceIds=instances)
print('started your instances: ' + str(instances))
Видео How to Automatically Stop/Start EC2 instances using AWS Lambda| Cloudwatch Events Scheduler канала Tech Nest
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Start Stop EC2 with Lambda PythonAWS Instance Scheduler Step by Step | Tutorial to automate EC2/RDS start/stop | Multi AccountHow to start and stop instances using lambda and CloudwatchSetup Scheduled Events aka CRON Jobs with AWS Cloudwatch EventsAWS Lambda Tutorial | Use AWS CloudWatch Events to schedule Lambda function invocationHow to Host a Website on Amazon Web Services (AWS) - S3, Route 53, CloudFront, & Certificate ManagerAmazon AWS EC2 Free Tier + Paid Instances Account How To Cancel ALL ServicesAWS - CloudWatch Metrics, Alarms, Pricing, Events, Detailed MonitoringCreate a Serverless Backend on AWS with Lambda and Aurora | Step by Step TutorialAWS IAM Tutorial | Identity And Access Management (IAM) | AWS Training Videos | EdurekaAWS Lambda - DEMO - Serverless code execution - Automate EBS Snapshot ExampleCollect Metrics and Logs from Amazon EC2 instances with the CloudWatch AgentAWS EC2 Stop and Restart an EC2 instanceAWS Lambda function | Copy files from one S3 bucket to another S3 bucket as soon as uploadedAWS - Scheduled shutdown and startup of the EC2 instances without AWS Instance SchedulerDeep Dive on Amazon EventBridge - AWS Online Tech Talksv1.0 - 230 ecs 4 schedule taskScheduled Start/Stop of EC2 Instances using Lambda and CloudWatch EventsUsing Terraform automate the process of stopping EC2 instance with AWS LambdaDeploy static website to AWS with HTTPS - S3, Route 53, CloudFront, Certificate Manager