Тёмный

How to Automatically Stop/Start EC2 instances using AWS Lambda| Cloudwatch Events Scheduler 

Tech Nest
Подписаться 2,2 тыс.
Просмотров 42 тыс.
50% 1

In this video we have walked through to Start/Stop instance using Lambda function and manage using Cloudwatch Events .
Refer Link : aws.amazon.com/premiumsupport...
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))

Опубликовано:

 

28 июн 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 48   
@Diegovalle90
@Diegovalle90 11 месяцев назад
Still working good in July 2023, thank you very much!
@thealchemist7597
@thealchemist7597 2 года назад
Guys,this is amazing. Thank you so much. Really amount of knowledge you are sharing in these free videos is incredible.
@technest6527
@technest6527 Год назад
Thanks
@sachindeshpande1
@sachindeshpande1 Год назад
Good tutorial! 12 -13 minutes video tutorial by two experts amazing!😀
@technest6527
@technest6527 Год назад
Thanks 🙏
@kirangunjal5806
@kirangunjal5806 Год назад
Nice, Thank you....
@technest6527
@technest6527 Год назад
Thank you too
@vishnukr4573
@vishnukr4573 2 года назад
Thanks for the video, it really helped me out:)
@technest6527
@technest6527 Год назад
Glad it helped.. thanks 🙏
@shaikaisha6657
@shaikaisha6657 2 года назад
If you can be little slower in moving your tabs and explaining that would be great help for beginners
@technest6527
@technest6527 Год назад
Sure from next video. Thanks for your feedback
@vijaykumarmadanu9810
@vijaykumarmadanu9810 Год назад
Really amazing video, thanks to both, you are awesome
@technest6527
@technest6527 Год назад
Our pleasure!
@sankarsiva3329
@sankarsiva3329 3 года назад
Super, please upload more aws videos thank you very much.
@technest6527
@technest6527 3 года назад
Sure ...will upload
@mindcoder4823
@mindcoder4823 2 года назад
what if you have multiple instances that you want to stop at a given time, do you put all the instance IDs and separate with comma?
@shahmalav3703
@shahmalav3703 4 года назад
Perfect I completely understand how to stop the instance but suppose if want stop every day at 9pm and start at next morning at 8am then what should I do
@leelachollangi3271
@leelachollangi3271 Год назад
Super video
@technest6527
@technest6527 Год назад
Thanks
@furkanshaikh5883
@furkanshaikh5883 2 года назад
Should we create lambda function of changing EC2 instance type as per CPU utilization.
@prateekverma9166
@prateekverma9166 2 года назад
if you are getting error in boto code, try to write instance ids in double quotes ie " " ity worked for me
@furkanshaikh5883
@furkanshaikh5883 2 года назад
Hi, there is something problem with event rule it's says Failed to get event buses with error: InvalidSignatureException: Signature not yet current Could you guide me?
@akshaysolanki8409
@akshaysolanki8409 3 года назад
if i am working on any instance which is connected with instance scheduler and if the instance is stop by instance scheduler then how i prevent this situation and i want an manual mail to continue run the instance or stop the instance
@bharat94524
@bharat94524 2 года назад
Is Lambda service comes in a free tier if we handle EC2 instance with it?
@TMD21Apr09
@TMD21Apr09 Год назад
We can also pause DocumentDB at every 7th day using Lambda function, right?
@hemakumar4366
@hemakumar4366 2 месяца назад
How to set up ecs container fails to start we can get an alert.
@lopo8000
@lopo8000 2 года назад
how can i stop and start an instance after statuschecks fails??
@senthilkumargopal1637
@senthilkumargopal1637 Год назад
How to calculate the Lambda running cost for this scheduler?
@AnilKumar-cz6hp
@AnilKumar-cz6hp Год назад
Nice Video. R u providing Live session on aws automation. Please let us know.
@technest6527
@technest6527 Год назад
Not now
@alwingeorgedaniel7812
@alwingeorgedaniel7812 3 года назад
can we reboot the instance by using this method
@praseebkdas25
@praseebkdas25 2 года назад
After starting the instances, if we need to start or run some commands in these instances, how we can perform the same.
@adityar6511
@adityar6511 2 года назад
Same question
@awsdevops5321
@awsdevops5321 3 года назад
Can you make video on how to stop instances on friday night at 12 am and start at monday morning 12 am.
@technest6527
@technest6527 Год назад
Sure
@mazharmiya123
@mazharmiya123 3 года назад
Nowadays lambda function gives error
@diptivlogs7489
@diptivlogs7489 11 месяцев назад
I am getting 403 error while creating lambda function
@jalajchaturvedi1
@jalajchaturvedi1 2 года назад
06:39 Lol....It stopped quite musically....
@technest6527
@technest6527 Год назад
😁
@vijayk4266
@vijayk4266 Год назад
Guys please do how to automatically stop RDS in all regions when it is running from more than 2hrs using cloudwatch and lambda
@technest6527
@technest6527 Год назад
Sure will do
@galleon8129
@galleon8129 8 месяцев назад
One chance
@kp490
@kp490 3 года назад
How to start stop based on status check failed event in cloud watch
@sharathshar
@sharathshar Год назад
bro why are you clicking sooooooooooo fast,,, its hard to catch you
@technest6527
@technest6527 Год назад
Oh
@harishgowdabp
@harishgowdabp 10 месяцев назад
Too fast 👎
Далее
Телеграмм-Колян Карелия
00:14
Просмотров 184 тыс.
когда мучает жажда // EVA mash
00:58
Просмотров 1,1 млн
EC2 Start Stop automatically using Lambda function
23:14
Deploy a Django web app with Nginx to Amazon EC2
35:26
AWS Cloudwatch Alarm Setup Tutorial | Step by Step
16:54
How to Start Stop RDS instances on schedule
7:25
Просмотров 4,3 тыс.
Телеграмм-Колян Карелия
00:14
Просмотров 184 тыс.