Using Python for Cloud Automations
- AWS Provides an SDK in python referred as boto3
- Lets create a virtual environment with boto3 installed
- Refer Here for boto3 docs
- For the application credentials we need access keys and secret key, configure as discussed in the class.
- To communicate with AWS we have to create client (low level apis) or Resource object (High level apis).
Activity 1: Start ec2 instance or stop a specific ec2 instance
- Refer Here for changes done
Activity 2: Get all the ec2 instances in every region with a tag Env = Dev
- get all the valid regions in my account using boto3
- get all ec2 instances of the region and perform action
- Refer Here for changes
Exercise
- Rotate IAM Credentials for a specific user
- Delete s3 bucket with name
- stop the rds instance
Serverless
- Refer Here for serverless
- Advantage:
- charged only when code is executing
- Scaling is handled by AWS
- Lets write a simple lambda function which adds two numbers
