Deploy with cdk deploy . 10.1 S3 upload with metadata s3.upload_file( "local.csv", "my-bucket", "data/upload.csv", ExtraArgs="Metadata": "source": "script" ) 10.2 DynamoDB batch write table = boto3.resource("dynamodb").Table("Users") with table.batch_writer() as batch: for user in users: batch.put_item(Item=user) 10.3 EC2 start/stop by tag ec2 = boto3.resource("ec2") instances = ec2.instances.filter( Filters=["Name": "tag:Environment", "Values": ["dev"]] ) for instance in instances: instance.stop() 11. Packaging & Dependencies for AWS 11.1 Lambda layers pip install requests -t python/ zip -r requests_layer.zip python/ Upload to Lambda as a layer. 11.2 Pure Python dependencies only Avoid native libraries ( cryptography , numpy ) unless using AWS Lambda Python 3.12 with arm64 or container images. 11.3 AWS SAM / CloudFormation Define a requirements.txt in your Lambda project:
pandoc python_aws_essentials.md -o python_aws_essentials.epub Or use ( ebook-convert ): python essentials for aws cloud developers epub
from aws_cdk import Stack, aws_s3 as s3 from constructs import Construct class MyStack(Stack): def (self, scope: Construct, id: str, **kwargs): super(). init (scope, id, **kwargs) s3.Bucket(self, "MyBucket", versioned=True) Deploy with cdk deploy
boto3>=1.28.0 requests SAM automatically packages them. | Service | Common actions | |-----------|-------------------------------------------------| | S3 | upload_file , download_file , generate_presigned_url | | EC2 | run_instances , describe_instances , stop_instances | | DynamoDB | get_item , put_item , query , update_item | | Lambda | invoke , update_function_code , list_functions | | CloudWatch| put_metric_data , get_metric_statistics | | STS | get_caller_identity (get current account/ARN) | End of document Converting to EPUB Save the content above as python_aws_essentials.md and run: generate_presigned_url | | EC2 | run_instances
import logging logger = logging.getLogger() logger.setLevel(logging.INFO) logger.info(f"Processing len(records) records") logger.error("Failed to connect", exc_info=True)
CloudWatch Logs automatically collect print() and logging output. AWS CDK uses Python to define cloud resources.