[PYTHON] Stop your AWS instance using Boto3

I wrote the process to stop the AWS instance in Boto3. I would like to get the tag, get the list, stop it in a group, stop it using Lambda, and so on.

I made it so much, so I will post it on my blog.

# -*- coding: utf-8 -*-

# import
import boto3
from boto3.session import Session

ec2 = boto3.client('ec2')
InstanceId = 'Instance ID'

# def
def ec2_stop():
  response = ec2.stop_instances(
    InstanceIds=[
      InstanceId
    ]
  )

# Main
if __name__ == "__main__":
  ec2_stop()

https://github.com/handa3/study/blob/master/aws/ec2/stop.py

Recommended Posts

Stop your AWS instance using Boto3
Stop an instance with a specific tag in Boto3
Addictive points when downloading files using boto on AWS Lambda
Try using AWS SageMaker Studio
Web scraping using AWS lambda
I tried using AWS Chalice
Create an AWS Cloud9 development environment on your Amazon EC2 instance
I stopped my instance at a specific time using AWS Lambda