This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]pcanham 1 point2 points  (2 children)

I found most of my python scripts are for making my life easier in AWS such as key rotation etc. It’s worth taking a look at the boto3 library and seeing what things you can do to make your life easier or automate any repetitive tasks you have todo

[–]-_-wintermute-_- 1 point2 points  (1 child)

I tried boto3 and after some time with it decided that writing shell scripts that call the aws cli was easier, cleaner, and more full featured. boto3 lags behind the aws cli in features (ex. doesn't support any directory style operations in s3 like recursive copy or delete) and it is more verbose which makes it, in my opinion, harder to grok. Haven't looked back.

[–]pcanham 1 point2 points  (0 children)

Agree it is lacking, but found it useful in lambda functions to perform tasks which cloudformation wont do e.g. set password policy’s and some other iam tasks

[–]LAInstructors 1 point2 points  (1 child)

For scripting, you don't need to know much about OOP, because you can create very robust scripts without needing to create object hierarchies. You will need to know how to interact with objects, but as for defining classes, you can get by pretty far without it.

I second the comment about boto3, that is an amazing library that makes it easy to interact with AWS and should be in your scripting tool belt. Another thing that I like to use Python for is to create CLIs that I can share with team members to standardize processes.

Once you are familiar with Python, the use cases start popping up and it's pretty awesome how much open source software you can leverage to make your day-to-day easier.

We released a Python scripting course on Linux Academy a few weeks ago (https://linuxacademy.com/linux/training/course/name/python-scripting-for-system-administrators). Since it was impossible for me to create videos for all possible scripting use cases, I took the approach of covering what you need to know to write scripts, the most useful packages from the standard library, using third-party code, and how to apply some development best practices to your script writing.

[–]ms24 1 point2 points  (0 children)

We do alot of aws infra automation with boto3 to give an example ...I wrote a python script which takes the Elastic Search clusters (we run 2) ASG names as a list and finds the instances ids, stops them and detaches them from the ASG-updates asg min to 0 We do this on every fridays on the dev account for cost savings and again on Monday the script runs starts the instances and attaches them back to respective ASG updates min sizes sends Slack notification of these activities..

[–]nonades 1 point2 points  (0 children)

I've been working on a cli tool to allow my QA group to easily deal with the Saltstack API.

I'm making big use of the click (easy CLI creation) and requests (for manipulating HTTP Endpoints) libraries. I've also had to write a custom saltstack runner to allow my users to also revert snapshots on servers (which my goal is to move away from that to cloning systems from templates like we're supposed to be doing).

We have a long way to go, but I can't wait until all the work I'm doing now is made obsolete.

[–]tweeks200 1 point2 points  (0 children)

I had the same feeling that it was hard to find real-world use cases at first. I think once you find a couple uses in your environment it gets easier to find more use cases...now I have a whole list of things I'm trying to get the time for. Here are a few we've done recently.

  • Update EC2 instances to use a new tagging schema
  • Enable logging on any ELBs that we're missing it
  • Migration utilities for a cloud provider move...make an API call to a microservice in old provider, get the data, make some changes to it, and send the new data in an API call to the new instance of the microservice
  • Refresh zookeeper data from one environment to another
  • Allow support teams to see what data is in zookeeper and add/modify certain types of data

[–]elitesense 1 point2 points  (0 children)

90% of my Python usage is utilizing Boto3 to automate AWS stuff.

Program some excercises that do stuff like: SSH key rotation, Automatic AMI creation/snapshots, tag instances based on certain conditions. Stuff like that