Provides infrastructure layer compute capabilities, including both bare metal and virtual servers with various optimizations includins compute, memory, IO, and disk. Also supports accelerations options such as GPUs, FPGAs, Inferentia and Trainium.
Provides image recognition capability for images (in batch or real-time) and video that provides a analysis of the content such as real-world objects, faces, celebrities, and path mapping.
Provides a publish/subscribe notification service with multiple subscription types including Amazon Simple Queue Service (SQS), Amazon Kinesis Data Firehose, AWS Lambda, generic HTTPS endpoints, SMS and email.
A serverless, fully-managed, message queue service that supports producing, store, and consuming messages and enables loose coupling between applications.
Provides private networking capability spanning multiple availability zones and supporting subnets, routing, network access control groups, security groups and gateways.
Provides tracing of service invocations in distributed applications for observability, allowing users to diagnose issues or optimize their service interactions.
All about Cloud, mostly about Amazon Web Services (AWS)
Automating with Python and Boto3
2017-03-25 / 494 words / 3 minutes
I worked as a professional software engineer for many years. First I wrote C code and built it using make. Later I wrote Java code and built it originally using Ant and then Maven. I’d written lots of enterprise applications which used the AWS Java SDK. At the other extreme, I’d written BASH shell scripts, including some which used the AWS CLI tools. I had never considered automating with Python and Boto3.
An organization was migrating to AWS and asked about automation and Infrastucture as Code. The Java approach was great for “Enterprise Applications”, but the build process introduced considerable turnaround time. The BASH approach provided instant feedback, but using the output from one command as the input to the next command was often awkward, and sometimes impossible. Python provided a good compromise.
Automating with Python and Boto3
A coworker suggested that I try automating with Python and Boto3. At first, I was horrified. A language which forced indentation to declare statement blocks? I thought that died with COBOL!
What I grew to love was the ability to write code without needing a build system. It was easy to call AWS APIs and use the results. I could find libraries to do almost anything that I needed. AWS Lambda supports Python.
I also realized that I always indent my Java code. The curly braces in Java were pretty much redundant.
The Python Way
There were other things to get used to. I was informed that these were “The Python Way”.
The most significant of these was about exception handling. In Java, code was carefully constructed not to throw exceptions. In Python, exceptions were used as a form of flow control. The whole idea of the try … else block was frightening.
The Python way did make things more efficient. Instead of making a call to AWS to determine state, and then another call to perform an action, Python would using a single call. The try…else construct adds some elegance to the approach. It allows the statement that might cause the exception to be independent of the code to run if there was no exception.
An Example Python and Boto3 App
The Boto3 library allows Python to talk to AWS. The following program will use the credentials setup by the aws configure CLI tool to connect to the default AWS account and list all the Amazon Simple Storage Service (S3) buckets. Lines 4 & 6 do the real work:
Simple Python Boto3 ScriptPython
import boto3
from botocore.exceptions import ClientError
All data and information provided on this site is for informational
purposes only. cloudninja.cloud makes no representations as to accuracy,
completeness, currentness, suitability, or validity of any information
on this site and will not be liable for any errors, omissions, or
delays in this information or any losses, injuries, or damages
arising from its display or use. All information is provided on an
as-is basis.
This is a personal weblog. The opinions expressed here represent my
own and not those of my employer. My opinions may change over time.