AWS › AWS CLI & SDKs

What are AWS SDKs, and how do they differ from using the CLI for programmatic access to AWS services?

Intermediate

Answer

AWS SDKs are libraries available for popular programming languages such as Python, JavaScript, Java, and Go that let developers interact with AWS services directly from within their application code, providing native language constructs, error handling, and automatic request signing, which is more appropriate for building applications that need to call AWS services as part of their runtime logic, compared to the CLI which is better suited for scripting and manual or automated operational tasks outside of an application's own codebase.
import boto3
s3 = boto3.client('s3')
s3.upload_file('local_file.txt', 'my-bucket', 'remote_file.txt')
Real-world example A web application uses the AWS SDK for Python, known as boto3, directly within its backend code to upload user uploaded files to S3 as part of handling an HTTP request, rather than shelling out to run CLI commands from within the application.

Common follow-ups: Which AWS SDKs are officially supported, and how do they compare in terms of features?;Can you mix CLI commands and SDK code within the same automation workflow?