[{"data":1,"prerenderedAt":2256},["ShallowReactive",2],{"post-cards":3,"categories":733,"post-package-a-python-lambda-as-a-docker-image":783},[4,29,44,61,80,102,113,130,147,161,178,192,207,222,235,244,253,267,281,295,305,318,328,338,349,364,376,389,400,411,422,433,444,455,468,481,496,511,525,539,551,562,573,583,593,603,613,623,633,643,653,663,673,683,693,703,713,723],{"path":5,"title":6,"slug":7,"summary":8,"date":9,"readTime":10,"hasImage":11,"category":12,"tags":17,"tagSlugs":28},"\u002Fposts\u002Fbuild-a-qr-code-lambda-and-call-it-from-laravel","Build a QR Code Lambda and Call It From Laravel","build-a-qr-code-lambda-and-call-it-from-laravel","A hands-on, beginner-friendly build: write a tiny Python AWS Lambda that turns text into a QR code, run it locally in Docker with no AWS account, and call it from a Laravel app. Every line of Python is explained for developers coming from PHP.","2026-06-15",10,true,{"id":13,"name":14,"slug":15,"hue":16},7,"AWS","aws",195,[18,19,22,25],{"name":14,"slug":15},{"name":20,"slug":21},"Lambda","lambda",{"name":23,"slug":24},"Docker","docker",{"name":26,"slug":27},"Laravel","laravel",[15,21,24,27],{"path":30,"title":31,"slug":32,"summary":33,"date":9,"readTime":10,"hasImage":11,"category":34,"tags":35,"tagSlugs":43},"\u002Fposts\u002Fdeploy-a-lambda-container-image-with-ecr-and-the-console","Deploy a Lambda Container Image With ECR and the Console","deploy-a-lambda-container-image-with-ecr-and-the-console","You built a QR code Lambda and ran it locally. Now put it on AWS the click-through way: create an Amazon ECR repository, push your image, and create the Lambda from that image in the console. Then test it and optionally expose it with a Function URL your Laravel app can call.",{"id":13,"name":14,"slug":15,"hue":16},[36,37,38,41,42],{"name":14,"slug":15},{"name":20,"slug":21},{"name":39,"slug":40},"ECR","ecr",{"name":23,"slug":24},{"name":26,"slug":27},[15,21,40,24,27],{"path":45,"title":46,"slug":47,"summary":48,"date":9,"readTime":49,"hasImage":11,"category":50,"tags":55,"tagSlugs":60},"\u002Fposts\u002Fpython-for-php-developers","Python for PHP Developers","python-for-php-developers","A friendly tour of Python for developers who already know modern PHP. We map the things you reach for every day, types, arrays, classes, named arguments, match, and enums, onto their Python equivalents so you can read and write Python with confidence.",12,{"id":51,"name":52,"slug":53,"hue":54},8,"Python","python",330,[56,57],{"name":52,"slug":53},{"name":58,"slug":59},"PHP","php",[53,59],{"path":62,"title":63,"slug":64,"summary":65,"date":66,"readTime":67,"hasImage":11,"category":68,"tags":71,"tagSlugs":79},"\u002Fposts\u002Fsolid-principles-modern-php","SOLID Principles in Modern PHP","solid-principles-modern-php","SOLID has not changed in years, but PHP has. Here are the five object-oriented design principles rewritten for PHP 8.5, using typed properties, readonly, enums, constructor promotion, and property hooks to express the same ideas with far less boilerplate.","2026-06-14T12:00:00",9,{"id":69,"name":58,"slug":59,"hue":70},1,264,[72,73,76],{"name":58,"slug":59},{"name":74,"slug":75},"OOP","oop",{"name":77,"slug":78},"Architecture","architecture",[59,75,78],{"path":81,"title":82,"slug":83,"summary":84,"date":85,"readTime":13,"hasImage":86,"category":87,"tags":92,"tagSlugs":101},"\u002Fposts\u002Fgit-flow-vs-github-flow-choosing-a-branching-strategy","Git Flow vs GitHub Flow: Choosing a Branching Strategy for Your Team","git-flow-vs-github-flow-choosing-a-branching-strategy","Git Flow and GitHub Flow take very different approaches to team branching and releases. Let's compare them, see where trunk-based development fits, and sort out how to handle versioned releases, hotfixes, and everything in between.","2026-06-14",false,{"id":88,"name":89,"slug":90,"hue":91},4,"Git","git",158,[93,95,98],{"name":94,"slug":90},"GIT",{"name":96,"slug":97},"Workflow","workflow",{"name":99,"slug":100},"GitHub","github",[90,97,100],{"path":103,"title":104,"slug":105,"summary":106,"date":85,"readTime":13,"hasImage":86,"category":107,"tags":108,"tagSlugs":112},"\u002Fposts\u002Fgithub-flow-keep-your-main-branch-deployable","GitHub Flow: Keep Your Main Branch Deployable","github-flow-keep-your-main-branch-deployable","GitHub Flow is the lightweight branching workflow built on a single rule: anything in main is deployable. Here is the whole loop, branch, pull request, review, merge and deploy, with the git and gh commands and an honest look at where it fits.",{"id":88,"name":89,"slug":90,"hue":91},[109,110,111],{"name":94,"slug":90},{"name":96,"slug":97},{"name":99,"slug":100},[90,97,100],{"path":114,"title":115,"slug":116,"summary":117,"date":118,"readTime":10,"hasImage":11,"category":119,"tags":120,"tagSlugs":129},"\u002Fposts\u002Forchestrating-lambdas-with-step-functions","Orchestrating Lambdas with Step Functions","orchestrating-lambdas-with-step-functions","Step Functions let you wire Lambdas into workflows with retries, branching, and parallelism, but you do not always need them. Here is an honest guide to when a state machine earns its keep, then a real parallel pipeline built with the modern JSONata syntax, deployed with SAM and tested locally.","2026-06-03",{"id":13,"name":14,"slug":15,"hue":16},[121,122,123,126],{"name":14,"slug":15},{"name":20,"slug":21},{"name":124,"slug":125},"Step Functions","step-functions",{"name":127,"slug":128},"Serverless","serverless",[15,21,125,128],{"path":131,"title":132,"slug":133,"summary":134,"date":135,"readTime":136,"hasImage":11,"category":137,"tags":138,"tagSlugs":146},"\u002Fposts\u002Fgive-your-lambda-an-http-front-door","Give Your Lambda an HTTP Front Door","give-your-lambda-an-http-front-door","Your Lambda works, but how should the world call it? This is a practical tour of the options: invoking directly, Lambda function URLs, and Amazon API Gateway, with a clear guide to what each one buys you. Then we build an HTTP API with SAM, test it locally, and call it from a Laravel app.","2026-05-06",11,{"id":13,"name":14,"slug":15,"hue":16},[139,140,141,144,145],{"name":14,"slug":15},{"name":20,"slug":21},{"name":142,"slug":143},"API Gateway","api-gateway",{"name":127,"slug":128},{"name":26,"slug":27},[15,21,143,128,27],{"path":148,"title":149,"slug":150,"summary":151,"date":152,"readTime":10,"hasImage":11,"category":153,"tags":154,"tagSlugs":160},"\u002Fposts\u002Fpackage-a-python-lambda-as-a-docker-image","Package a Python Lambda as a Docker Image","package-a-python-lambda-as-a-docker-image","AWS Lambda is not just zip files. Here is how to package a Python function as a Docker container image, choose between arm64 and x86_64, test it locally with the Runtime Interface Emulator, push it to Amazon ECR, and invoke it directly without any API Gateway in front.","2026-04-08",{"id":13,"name":14,"slug":15,"hue":16},[155,156,157,158,159],{"name":14,"slug":15},{"name":20,"slug":21},{"name":23,"slug":24},{"name":39,"slug":40},{"name":127,"slug":128},[15,21,24,40,128],{"path":162,"title":163,"slug":164,"summary":165,"date":166,"readTime":167,"hasImage":11,"category":168,"tags":169,"tagSlugs":177},"\u002Fposts\u002Fwhats-new-in-php-8-5","What's New in PHP 8.5","whats-new-in-php-8-5","PHP 8.5 leans into composition and ergonomics. Here are its headline features with practical examples: the pipe operator, cloning with property updates, the NoDiscard attribute, array_first and array_last, the new URI extension, and backtraces on fatal errors.","2025-11-22",6,{"id":69,"name":58,"slug":59,"hue":70},[170,171,174],{"name":58,"slug":59},{"name":172,"slug":173},"PHP 8.5","php-8-5",{"name":175,"slug":176},"What's New","whats-new",[59,173,176],{"path":179,"title":180,"slug":181,"summary":182,"date":183,"readTime":167,"hasImage":11,"category":184,"tags":185,"tagSlugs":191},"\u002Fposts\u002Fwhats-new-in-php-8-4","What's New in PHP 8.4","whats-new-in-php-8-4","PHP 8.4 brought one of the biggest syntax additions of the 8.x line. Here are its headline features with practical examples: property hooks, asymmetric visibility, new without parentheses, the array_find family, the Deprecated attribute, and a modern HTML5 DOM parser.","2024-11-23",{"id":69,"name":58,"slug":59,"hue":70},[186,187,190],{"name":58,"slug":59},{"name":188,"slug":189},"PHP 8.4","php-8-4",{"name":175,"slug":176},[59,189,176],{"path":193,"title":194,"slug":195,"summary":196,"date":197,"readTime":198,"hasImage":86,"category":199,"tags":203,"tagSlugs":206},"\u002Fposts\u002Fstarting-with-rust-installation-first-program","Starting with Rust: From Installation to Your First Program","starting-with-rust-installation-first-program","Learn how to install Rust and write your first \"Hello, world!\" program.","2024-03-23",2,{"id":167,"name":200,"slug":201,"hue":202},"Rust","rust-programming",38,[204],{"name":205,"slug":205},"rust",[205],{"path":208,"title":209,"slug":210,"summary":211,"date":212,"readTime":213,"hasImage":11,"category":214,"tags":215,"tagSlugs":221},"\u002Fposts\u002Fwhats-new-in-php-8-3","What's New in PHP 8.3","whats-new-in-php-8-3","PHP 8.3 is a focused release full of quality-of-life wins. Here are its headline features with practical examples: typed class constants, the Override attribute, json_validate, dynamic constant fetch, random string generation, and readonly deep cloning.","2023-11-25",5,{"id":69,"name":58,"slug":59,"hue":70},[216,217,220],{"name":58,"slug":59},{"name":218,"slug":219},"PHP 8.3","php-8-3",{"name":175,"slug":176},[59,219,176],{"path":223,"title":224,"slug":225,"summary":226,"date":227,"readTime":198,"hasImage":86,"category":228,"tags":232,"tagSlugs":234},"\u002Fposts\u002Fflutter-version-management-fvm","Flutter Version Management","flutter-version-management-fvm","Managing multiple Flutter versions does not need not be a headache. Let's jump into FVM and see how it can simplify your Flutter journey.","2023-10-07",{"id":213,"name":229,"slug":230,"hue":231},"Flutter","flutter",230,[233],{"name":230,"slug":230},[230],{"path":236,"title":237,"slug":238,"summary":239,"date":227,"readTime":69,"hasImage":86,"category":240,"tags":241,"tagSlugs":243},"\u002Fposts\u002Fsetting-up-cocoapods-fvm","Setting Up CocoaPods for FVM-managed Flutter Projects","setting-up-cocoapods-fvm","A guide to installing CocoaPods for a Flutter project while using FVM to manage Flutter versions, ensuring a smooth setup for iOS development.",{"id":213,"name":229,"slug":230,"hue":231},[242],{"name":230,"slug":230},[230],{"path":245,"title":246,"slug":247,"summary":248,"date":227,"readTime":69,"hasImage":86,"category":249,"tags":250,"tagSlugs":252},"\u002Fposts\u002Ftroubleshooting-xcode-15-build-issues-flutter","Troubleshooting Xcode 15 Build Issues in Flutter Projects","troubleshooting-xcode-15-build-issues-flutter","Uncovering solutions to common issues faced when updating to Xcode 15 in a Flutter project using an older version of CocoaPods.",{"id":213,"name":229,"slug":230,"hue":231},[251],{"name":230,"slug":230},[230],{"path":254,"title":255,"slug":256,"summary":257,"date":258,"readTime":167,"hasImage":11,"category":259,"tags":260,"tagSlugs":266},"\u002Fposts\u002Fwhats-new-in-php-8-2","What's New in PHP 8.2","whats-new-in-php-8-2","PHP 8.2 polished the type system and the immutability story. Here are its headline features with practical examples: readonly classes, DNF types, standalone null, false and true types, the new Random extension, constants in traits, and sensitive parameter redaction.","2022-12-10",{"id":69,"name":58,"slug":59,"hue":70},[261,262,265],{"name":58,"slug":59},{"name":263,"slug":264},"PHP 8.2","php-8-2",{"name":175,"slug":176},[59,264,176],{"path":268,"title":269,"slug":270,"summary":271,"date":272,"readTime":167,"hasImage":11,"category":273,"tags":274,"tagSlugs":280},"\u002Fposts\u002Fwhats-new-in-php-8-1","What's New in PHP 8.1","whats-new-in-php-8-1","PHP 8.1 is one of the most loved releases of the 8.x line. Here are its headline features with practical examples: enums, readonly properties, first-class callable syntax, fibers, the never return type, and new in initializers.","2021-11-27",{"id":69,"name":58,"slug":59,"hue":70},[275,276,279],{"name":58,"slug":59},{"name":277,"slug":278},"PHP 8.1","php-8-1",{"name":175,"slug":176},[59,278,176],{"path":282,"title":283,"slug":284,"summary":285,"date":286,"readTime":167,"hasImage":11,"category":287,"tags":288,"tagSlugs":294},"\u002Fposts\u002Fwhats-new-in-php-8-0","What's New in PHP 8.0","whats-new-in-php-8-0","PHP 8.0 was a true major version. Here is a tour of its headline features with practical examples: constructor property promotion, named arguments, the match expression, the nullsafe operator, union types, and string helpers that finally read like English.","2020-11-28",{"id":69,"name":58,"slug":59,"hue":70},[289,290,293],{"name":58,"slug":59},{"name":291,"slug":292},"PHP 8.0","php-8-0",{"name":175,"slug":176},[59,292,176],{"path":296,"title":297,"slug":298,"summary":299,"date":300,"readTime":88,"hasImage":86,"category":301,"tags":302,"tagSlugs":304},"\u002Fposts\u002Fgit-tracking-a-remote-branch-upstream-for-changes","Git: Tracking a Remote Branch for Changes","git-tracking-a-remote-branch-upstream-for-changes","When you fork a project, you need a way to pull in changes from the original repository, usually called upstream. Here is how to wire up an upstream remote, actually sync your fork, and set up branch tracking so plain git pull and git push just work.","2018-11-04",{"id":88,"name":89,"slug":90,"hue":91},[303],{"name":94,"slug":90},[90],{"path":306,"title":307,"slug":308,"summary":309,"date":300,"readTime":310,"hasImage":11,"category":311,"tags":315,"tagSlugs":317},"\u002Fposts\u002Fjavascript-array-map-filter-reduce-functions","JavaScript's map, filter, and reduce methods","javascript-array-map-filter-reduce-functions","JavaScript provides some amazing functions that can be called against your arrays to help filter them, manipulate them, or even reduce them down to a single value or grouped values.",3,{"id":198,"name":312,"slug":313,"hue":314},"JavaScript","javascript",92,[316],{"name":312,"slug":313},[313],{"path":319,"title":320,"slug":321,"summary":322,"date":323,"readTime":69,"hasImage":11,"category":324,"tags":325,"tagSlugs":327},"\u002Fposts\u002Fphp-fizzbuzz-example","FizzBuzz in PHP: A Fresh Approach","php-fizzbuzz-example","FizzBuzz is a very popular programming question that tests your logic to see if you can build a simple program.","2018-11-02",{"id":69,"name":58,"slug":59,"hue":70},[326],{"name":58,"slug":59},[59],{"path":329,"title":330,"slug":331,"summary":332,"date":333,"readTime":198,"hasImage":11,"category":334,"tags":335,"tagSlugs":337},"\u002Fposts\u002Fphp-array-reduce","PHP's array_reduce is not only for outputting single values","php-array-reduce","PHP's array_reduce is a simple way to partition a set of data or return a single value. It is super powerful and worth spending time learning.","2018-11-01",{"id":69,"name":58,"slug":59,"hue":70},[336],{"name":58,"slug":59},[59],{"path":339,"title":340,"slug":341,"summary":342,"date":343,"readTime":167,"hasImage":86,"category":344,"tags":345,"tagSlugs":348},"\u002Fposts\u002Fimprove-your-git-workflow-with-git-flow","Improve Your Git Workflow with Git Flow","improve-your-git-workflow-with-git-flow","Git Flow is a structured branching model built around versioned, scheduled releases. Here is how its branches fit together, a hands-on walkthrough of features, releases and hotfixes, and an honest take on when it is still the right call.","2016-12-06",{"id":88,"name":89,"slug":90,"hue":91},[346,347],{"name":94,"slug":90},{"name":96,"slug":97},[90,97],{"path":350,"title":351,"slug":352,"summary":353,"date":354,"readTime":167,"hasImage":86,"category":355,"tags":359,"tagSlugs":363},"\u002Fposts\u002Fusing-css-transitions","Using CSS Transitions","using-css-transitions","CSS transitions are the standard way to apply transitions to your elements, and have been for years, replacing the old approach of using JavaScript. In this article, I'll go through each of the transition properties available, and provide examples of how to use them.","2016-12-05",{"id":310,"name":356,"slug":357,"hue":358},"HTML & CSS","html-css",55,[360],{"name":361,"slug":362},"CSS","css",[362],{"path":365,"title":366,"slug":367,"summary":368,"date":369,"readTime":88,"hasImage":86,"category":370,"tags":371,"tagSlugs":375},"\u002Fposts\u002Fstructuring-your-website-with-html-5-semantics","Structuring Your Website With HTML 5 Semantics","structuring-your-website-with-html-5-semantics","Prior to HTML 5, there was no real markup to help explain the intent behind your HTML code. The goal of HTML 5 was to offer a more readable way of writing your code, so that any author that comes after you can have an easier time going through what you've created.","2016-12-04",{"id":310,"name":356,"slug":357,"hue":358},[372],{"name":373,"slug":374},"HTML","html",[374],{"path":377,"title":378,"slug":379,"summary":380,"date":381,"readTime":198,"hasImage":86,"category":382,"tags":383,"tagSlugs":388},"\u002Fposts\u002Finterpolation-in-stylus-css-pre-processor","Interpolation in Stylus","interpolation-in-stylus-css-pre-processor","You can also use interpolation to improve your functions for reuse, as well as your other code within your stylesheet. The way it works is that you can wrap your expression within {}, which will then be outputted as the identifier.","2016-12-03",{"id":310,"name":356,"slug":357,"hue":358},[384,387],{"name":385,"slug":386},"Stylus","stylus",{"name":361,"slug":362},[386,362],{"path":390,"title":391,"slug":392,"summary":393,"date":394,"readTime":69,"hasImage":86,"category":395,"tags":396,"tagSlugs":399},"\u002Fposts\u002Fcreating-configuration-files-in-stylus-css-pre-processor","Creating Configuration Files In Stylus","creating-configuration-files-in-stylus-css-pre-processor","It's super simple to create a configuration file for instance that would manage your media query break points. You could also use a configuration file for managing colors, font sizes, and other variables such as gutter spacing and more.","2016-12-02",{"id":310,"name":356,"slug":357,"hue":358},[397,398],{"name":361,"slug":362},{"name":385,"slug":386},[362,386],{"path":401,"title":402,"slug":403,"summary":404,"date":405,"readTime":88,"hasImage":86,"category":406,"tags":407,"tagSlugs":410},"\u002Fposts\u002Fusing-functions-and-mixins-with-stylus-css-pre-processor","Using Functions and Mixins with Stylus","using-functions-and-mixins-with-stylus-css-pre-processor","Stylus allows you to create functions and mixins of reusable code for your stylesheets. You can also handle mathematical operations, unary operations, and more allowing you complete control over your stylesheets with ease.","2016-12-01",{"id":310,"name":356,"slug":357,"hue":358},[408,409],{"name":361,"slug":362},{"name":385,"slug":386},[362,386],{"path":412,"title":413,"slug":414,"summary":415,"date":416,"readTime":198,"hasImage":86,"category":417,"tags":418,"tagSlugs":421},"\u002Fposts\u002Fsetting-variables-in-stylus-css-pre-processor","Setting Variables in Stylus","setting-variables-in-stylus-css-pre-processor","Unlike CSS, in Stylus you can assign expressions to variables that can be reusable throughout your stylesheets.","2016-11-29",{"id":310,"name":356,"slug":357,"hue":358},[419,420],{"name":361,"slug":362},{"name":385,"slug":386},[362,386],{"path":423,"title":424,"slug":425,"summary":426,"date":427,"readTime":213,"hasImage":86,"category":428,"tags":429,"tagSlugs":432},"\u002Fposts\u002Fusing-selectors-in-stylus-css-pre-processor","Using Selectors in Stylus","using-selectors-in-stylus-css-pre-processor","Selectors are a way to pick the elements that you want styled. In Stylus, similar to CSS, you can apply a set of styles to any element by separating them by a comma delimited list. Stylus though, also allows you to select multiple elements by separating each on their own line.","2016-11-28",{"id":310,"name":356,"slug":357,"hue":358},[430,431],{"name":361,"slug":362},{"name":385,"slug":386},[362,386],{"path":434,"title":435,"slug":436,"summary":437,"date":438,"readTime":69,"hasImage":86,"category":439,"tags":440,"tagSlugs":443},"\u002Fposts\u002Flearning-stylus-a-css-pre-processor","Learning Stylus: A CSS Pre-Processor","learning-stylus-a-css-pre-processor","This mini-series will be a little different to how you may see other articles on my site. Really this article is more geared as notes for me as I go through the documentation for Stylus, and learn the ins and outs of this beautiful language.","2016-11-27",{"id":310,"name":356,"slug":357,"hue":358},[441,442],{"name":361,"slug":362},{"name":385,"slug":386},[362,386],{"path":445,"title":446,"slug":447,"summary":448,"date":449,"readTime":88,"hasImage":86,"category":450,"tags":451,"tagSlugs":454},"\u002Fposts\u002Fbem-methodology-overview-and-naming-conventions","BEM Methodology Overview and Naming Conventions","bem-methodology-overview-and-naming-conventions","BEM or Block Element Modifier is a naming convention used to help organize your code base. In this article, I discuss its uses within your CSS projects.","2016-11-26",{"id":310,"name":356,"slug":357,"hue":358},[452,453],{"name":361,"slug":362},{"name":373,"slug":374},[362,374],{"path":456,"title":457,"slug":458,"summary":459,"date":460,"readTime":69,"hasImage":86,"category":461,"tags":462,"tagSlugs":467},"\u002Fposts\u002Fintroduction-to-ecmascript-6","Introduction to ECMAScript 6","introduction-to-ecmascript-6","The latest in ECMAScript 6 introduces new features to JavaScript which makes it so much more fun to use, while solving problems that have been around for years. The intent of this article is to provide you with resources you can use to start learning ES6 today.","2016-11-25",{"id":198,"name":312,"slug":313,"hue":314},[463,464],{"name":312,"slug":313},{"name":465,"slug":466},"ECMAScript","ecmascript",[313,466],{"path":469,"title":470,"slug":471,"summary":472,"date":473,"readTime":310,"hasImage":86,"category":474,"tags":475,"tagSlugs":480},"\u002Fposts\u002Fbabel-installation-and-configuration","Babel Installation and Configuration","babel-installation-and-configuration","Babel offers a convenient way to transform your ES6 code to JavaScript that all browsers can understand. In this article we'll go over a basic configuration that will enable you to start using it with any project right away.","2016-11-24",{"id":198,"name":312,"slug":313,"hue":314},[476,477],{"name":312,"slug":313},{"name":478,"slug":479},"Babel","babel",[313,479],{"path":482,"title":483,"slug":484,"summary":485,"date":486,"readTime":69,"hasImage":86,"category":487,"tags":488,"tagSlugs":495},"\u002Fposts\u002Fconfiguring-stylus-css-pre-processor-with-gulp-and-sourcemaps","Configuring Stylus CSS Pre-Processor with Gulp and Sourcemaps","configuring-stylus-css-pre-processor-with-gulp-and-sourcemaps","In this article we'll go over how to configure your project to process Stylus files using Gulp. We'll also create source map file which your browser will use to help point you in the right direction of your files when developing","2016-11-23",{"id":198,"name":312,"slug":313,"hue":314},[489,490,491,492],{"name":312,"slug":313},{"name":385,"slug":386},{"name":361,"slug":362},{"name":493,"slug":494},"Gulp","gulp",[313,386,362,494],{"path":497,"title":498,"slug":499,"summary":500,"date":501,"readTime":198,"hasImage":86,"category":502,"tags":503,"tagSlugs":510},"\u002Fposts\u002Fconfiguring-gulp-with-less-css-pre-processor","Configuring Gulp With Less CSS Pre-Processor","configuring-gulp-with-less-css-pre-processor","Less is a CSS pre-processor allowing you to create variables, mixins, and functions in an effort to make your CSS more maintainable.","2016-11-22",{"id":198,"name":312,"slug":313,"hue":314},[504,505,506,509],{"name":493,"slug":494},{"name":312,"slug":313},{"name":507,"slug":508},"Less","less",{"name":361,"slug":362},[494,313,508,362],{"path":512,"title":513,"slug":514,"summary":515,"date":516,"readTime":198,"hasImage":11,"category":517,"tags":518,"tagSlugs":524},"\u002Fposts\u002Fusing-browser-sync-with-gulp-for-live-reloading","Using Browser Sync with Gulp for Live Reloading","using-browser-sync-with-gulp-for-live-reloading","Browser Sync is a nice tool to use while developing. It allows your browser to reload live when changes are made to your files. For instance, assuming we're watching our CSS file for changes we can have the browser auto refresh\u002Fsync when it sees those changes made.","2016-11-21",{"id":198,"name":312,"slug":313,"hue":314},[519,520,523],{"name":312,"slug":313},{"name":521,"slug":522},"Browser Sync","browser-sync",{"name":493,"slug":494},[313,522,494],{"path":526,"title":527,"slug":528,"summary":529,"date":530,"readTime":198,"hasImage":86,"category":531,"tags":532,"tagSlugs":538},"\u002Fposts\u002Fgulp-watch-automate-your-gulp-tasks","Gulp Watch: Automate Your Gulp Tasks","gulp-watch-automate-your-gulp-tasks","Gulp watch is perfect for when you're editing project files since it allows you to not have to run the gulp command manually each time.","2016-11-20",{"id":198,"name":312,"slug":313,"hue":314},[533,534,537],{"name":312,"slug":313},{"name":535,"slug":536},"Yarn","yarn",{"name":493,"slug":494},[313,536,494],{"path":540,"title":541,"slug":542,"summary":543,"date":544,"readTime":167,"hasImage":86,"category":545,"tags":546,"tagSlugs":550},"\u002Fposts\u002Fconfiguring-gulp-on-a-new-project","Configuring Gulp On A New Project","configuring-gulp-on-a-new-project","Gulp may seem like a scary thing to wrap your head around at first, but it's actually quite easy to start using once you understand the basics.","2016-11-19",{"id":198,"name":312,"slug":313,"hue":314},[547,548,549],{"name":312,"slug":313},{"name":493,"slug":494},{"name":535,"slug":536},[313,494,536],{"path":552,"title":553,"slug":554,"summary":555,"date":556,"readTime":310,"hasImage":86,"category":557,"tags":558,"tagSlugs":561},"\u002Fposts\u002Fyarn-publishing-a-package","Yarn: Publishing a Package","yarn-publishing-a-package","Publishing a package to the npm repository has never been simpler. With a few steps, you can create a package that is redistributable to all of your projects.","2016-11-18",{"id":198,"name":312,"slug":313,"hue":314},[559,560],{"name":312,"slug":313},{"name":535,"slug":536},[313,536],{"path":563,"title":564,"slug":565,"summary":566,"date":567,"readTime":310,"hasImage":86,"category":568,"tags":569,"tagSlugs":572},"\u002Fposts\u002Fyarn-fast-and-secure-dependency-management","Yarn: Fast and Secure Dependency Management","yarn-fast-and-secure-dependency-management","Yarn is a super simple dependency management tool which is way faster to use instead of traditional npm. It acts as a drop-in replacement, so you can get started using yarn right away. The best way to install yarn is by using npm.","2016-11-17",{"id":198,"name":312,"slug":313,"hue":314},[570,571],{"name":312,"slug":313},{"name":535,"slug":536},[313,536],{"path":574,"title":575,"slug":576,"summary":577,"date":578,"readTime":69,"hasImage":11,"category":579,"tags":580,"tagSlugs":582},"\u002Fposts\u002Fsupport-for-keys-in-list-or-its-new-shorthand-syntax-in-php","Support for keys in list(), or its new shorthand syntax [] in PHP","support-for-keys-in-list-or-its-new-shorthand-syntax-in-php","Now as of PHP 7.1, you can define the keys of your array that will be parsed when destructuring your arrays. Prior to PHP 7.1, you could only use arrays with numeric indexes. Now with this new addition, our lives just got easier.","2016-11-16",{"id":69,"name":58,"slug":59,"hue":70},[581],{"name":58,"slug":59},[59],{"path":584,"title":585,"slug":586,"summary":587,"date":588,"readTime":69,"hasImage":11,"category":589,"tags":590,"tagSlugs":592},"\u002Fposts\u002Ftype-hinting-with-the-iterable-pseudo-type-in-php","Type Hinting With The Iterable pseudo-type In PHP","type-hinting-with-the-iterable-pseudo-type-in-php","As of PHP 7.1, you can now type hint your method\u002Ffunction arguments with the keyword iterable for handling arrays or even objects that implement the Traversable interface.","2016-11-15",{"id":69,"name":58,"slug":59,"hue":70},[591],{"name":58,"slug":59},[59],{"path":594,"title":595,"slug":596,"summary":597,"date":598,"readTime":69,"hasImage":11,"category":599,"tags":600,"tagSlugs":602},"\u002Fposts\u002Ftype-hinting-callable-functions-in-php","Type Hinting Callable Functions in PHP","type-hinting-callable-functions-in-php","As of PHP 5.4, you can type hint your method arguments with the callable keyword allowing you to enforce the type of data that is passed via your arguments.","2016-11-14",{"id":69,"name":58,"slug":59,"hue":70},[601],{"name":58,"slug":59},[59],{"path":604,"title":605,"slug":606,"summary":607,"date":608,"readTime":69,"hasImage":11,"category":609,"tags":610,"tagSlugs":612},"\u002Fposts\u002Fsetting-visibility-for-your-class-constants-in-php","Setting Visibility for Your Class Constants in PHP","setting-visibility-for-your-class-constants-in-php","Now in PHP 7.1+, you can set different visibility modifiers for each of your class constants. The available visibility modifiers consist of public, protected, and private.","2016-11-13",{"id":69,"name":58,"slug":59,"hue":70},[611],{"name":58,"slug":59},[59],{"path":614,"title":615,"slug":616,"summary":617,"date":618,"readTime":69,"hasImage":11,"category":619,"tags":620,"tagSlugs":622},"\u002Fposts\u002Fanonymous-classes-php","Using Anonymous Classes in PHP","anonymous-classes-php","As of PHP 7, you can now create quick throwaway objects for use within your projects. This can be especially useful for your automated tests, for instance, with allowing you to create quick implementations of your interfaces.","2016-11-12",{"id":69,"name":58,"slug":59,"hue":70},[621],{"name":58,"slug":59},[59],{"path":624,"title":625,"slug":626,"summary":627,"date":628,"readTime":69,"hasImage":11,"category":629,"tags":630,"tagSlugs":632},"\u002Fposts\u002Fsymmetric-array-destructuring-in-php","Symmetric Array Destructuring in PHP","symmetric-array-destructuring-in-php","As of PHP 7.1, you can now use the shorthand array syntax to destructure your arrays for assignment. Previously you would have had to use a function like list, but now you can use the simple new array shorthand syntax.","2016-11-11",{"id":69,"name":58,"slug":59,"hue":70},[631],{"name":58,"slug":59},[59],{"path":634,"title":635,"slug":636,"summary":637,"date":638,"readTime":198,"hasImage":11,"category":639,"tags":640,"tagSlugs":642},"\u002Fposts\u002Fphp-array-map-to-format-your-arrays-without-loops","Using PHP's array_map to format your arrays without loops","php-array-map-to-format-your-arrays-without-loops","So let's face it, loops are a bit boring. So how can we mix it up? Let's assume we have a case where we have a CSV file that we want to quickly parse.","2016-11-10",{"id":69,"name":58,"slug":59,"hue":70},[641],{"name":58,"slug":59},[59],{"path":644,"title":645,"slug":646,"summary":647,"date":648,"readTime":13,"hasImage":11,"category":649,"tags":650,"tagSlugs":652},"\u002Fposts\u002Fsolid-principles-in-php","SOLID Principles in PHP","solid-principles-in-php","The 5 basic principles for Object-Oriented Design, SOLID, were first created in an effort to improve maintainability in our code bases. SOLID is a mnemonic acronym that stands for each of the following principles: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.","2016-11-09",{"id":69,"name":58,"slug":59,"hue":70},[651],{"name":58,"slug":59},[59],{"path":654,"title":655,"slug":656,"summary":657,"date":658,"readTime":69,"hasImage":11,"category":659,"tags":660,"tagSlugs":662},"\u002Fposts\u002Ffiltering-arrays-without-using-loops-in-php","Filtering Arrays Without Using Loops in PHP","filtering-arrays-without-using-loops-in-php","PHP has a built-in function called array_filter that allows you to filter through your arrays without the need for a loop. Personally, this approach feels much cleaner to me and simpler to comprehend.","2016-11-08",{"id":69,"name":58,"slug":59,"hue":70},[661],{"name":58,"slug":59},[59],{"path":664,"title":665,"slug":666,"summary":667,"date":668,"readTime":69,"hasImage":11,"category":669,"tags":670,"tagSlugs":672},"\u002Fposts\u002Fvoid-return-types-in-php","Void Return Types in PHP","void-return-types-in-php","As of PHP 7.1, we can now use void return types within our methods. This is useful for cases where you have methods that are just setting or processing data without the need of returning any values.","2016-11-07",{"id":69,"name":58,"slug":59,"hue":70},[671],{"name":58,"slug":59},[59],{"path":674,"title":675,"slug":676,"summary":677,"date":678,"readTime":69,"hasImage":11,"category":679,"tags":680,"tagSlugs":682},"\u002Fposts\u002Ftype-hinting-with-nullable-types-in-php","Type Hinting with Nullable Types in PHP","type-hinting-with-nullable-types-in-php","As of PHP 7.1, you can now set your type declarations as nullable by simply prefixing them with a question mark ?. In doing so a null value can be passed in as a parameter or returned as a value for your methods.","2016-11-06",{"id":69,"name":58,"slug":59,"hue":70},[681],{"name":58,"slug":59},[59],{"path":684,"title":685,"slug":686,"summary":687,"date":688,"readTime":69,"hasImage":11,"category":689,"tags":690,"tagSlugs":692},"\u002Fposts\u002Fphp-group-multiple-use-declarations","PHP Group Multiple use Declarations","php-group-multiple-use-declarations","As of PHP 7, you can now group your imported classes, functions, and constants from under the same namespace.","2016-11-05",{"id":69,"name":58,"slug":59,"hue":70},[691],{"name":58,"slug":59},[59],{"path":694,"title":695,"slug":696,"summary":697,"date":698,"readTime":69,"hasImage":11,"category":699,"tags":700,"tagSlugs":702},"\u002Fposts\u002Fphp-null-coalescing-operator","PHP Null Coalescing Operator","php-null-coalescing-operator","One of my new favorite additions to PHP 7, is the Null Coalescing Operator. It cleans up your code by removing a tedious step of checking if some value is isset() and not NULL and returning it or if not setting a default.","2016-11-04",{"id":69,"name":58,"slug":59,"hue":70},[701],{"name":58,"slug":59},[59],{"path":704,"title":705,"slug":706,"summary":707,"date":708,"readTime":198,"hasImage":11,"category":709,"tags":710,"tagSlugs":712},"\u002Fposts\u002Fphp-spaceship-operator","PHP Spaceship Operator","php-spaceship-operator","One of the new features to hit PHP 7 is the Spaceship Operator. This new trick helps improve the way you'd compare 2 expressions. In short, the comparison returns 1 of 3 values (-1, 0, or 1) depending on the result of the comparison.","2016-11-03",{"id":69,"name":58,"slug":59,"hue":70},[711],{"name":58,"slug":59},[59],{"path":714,"title":715,"slug":716,"summary":717,"date":718,"readTime":310,"hasImage":11,"category":719,"tags":720,"tagSlugs":722},"\u002Fposts\u002Freturn-type-declarations-in-php","Return Type Declarations in PHP","return-type-declarations-in-php","PHP 7 now makes it possible to declare return types for your methods. This allows you better control over the data that will be returned from each method in your application.","2016-11-02",{"id":69,"name":58,"slug":59,"hue":70},[721],{"name":58,"slug":59},[59],{"path":724,"title":725,"slug":726,"summary":727,"date":728,"readTime":69,"hasImage":11,"category":729,"tags":730,"tagSlugs":732},"\u002Fposts\u002Fscalar-type-hints-php","Scalar Type Hints in PHP","scalar-type-hints-php","Starting with PHP 7.0, it's now possible to declare scalar type hints for your method arguments. Previously, we were able to use array and callable, but now with PHP 7+, we have much more control.","2016-11-01",{"id":69,"name":58,"slug":59,"hue":70},[731],{"name":58,"slug":59},[59],[734,741,747,753,759,765,771,777],{"id":735,"description":736,"extension":737,"hue":70,"meta":738,"name":58,"slug":59,"stem":739,"weight":69,"__hash__":740},"categories\u002Fcategories\u002Fphp.json","PHP articles and tutorials ranging from new language features to using interesting packages.","json",{},"categories\u002Fphp","h_EmN4YMO4b2mBt3MPLs7RvscJx0NBmwDIZPxqPqKLE",{"id":742,"description":743,"extension":737,"hue":314,"meta":744,"name":312,"slug":313,"stem":745,"weight":198,"__hash__":746},"categories\u002Fcategories\u002Fjavascript.json","JavaScript articles and tutorials ranging from new language features to using interesting packages.",{},"categories\u002Fjavascript","7gmVgkw5BRo26i1bFoSv96bwDJ4nTtZcJ9Ud6u5p0yk",{"id":748,"description":749,"extension":737,"hue":358,"meta":750,"name":356,"slug":357,"stem":751,"weight":310,"__hash__":752},"categories\u002Fcategories\u002Fhtml-css.json","HTML & CSS articles and tutorials ranging from new language features to using interesting packages.",{},"categories\u002Fhtml-css","vXvPlRA-iaeCJ64Wi3sLyUR0kqL48zYcZWORRqt8N70",{"id":754,"description":755,"extension":737,"hue":91,"meta":756,"name":89,"slug":90,"stem":757,"weight":88,"__hash__":758},"categories\u002Fcategories\u002Fgit.json","Git articles and tutorials ranging from new language features to different workflows.",{},"categories\u002Fgit","qOqFsFTKI9XB444UodUKW_3AakFadHzW-ss8V-maUmE",{"id":760,"description":761,"extension":737,"hue":231,"meta":762,"name":229,"slug":230,"stem":763,"weight":213,"__hash__":764},"categories\u002Fcategories\u002Fflutter.json","Dive into Flutter, the open-source UI software development toolkit, as we explore its capabilities in creating natively compiled applications for mobile, web, and desktop from a single codebase.",{},"categories\u002Fflutter","aD1moU8CgoYt4FRnSeA4Iy9xxnnopdEKBEYP2arAzdI",{"id":766,"description":767,"extension":737,"hue":202,"meta":768,"name":200,"slug":201,"stem":769,"weight":167,"__hash__":770},"categories\u002Fcategories\u002Frust-programming.json","From setting up your environment to advanced concepts, this is your go-to resource for all things Rust.",{},"categories\u002Frust-programming","LscnqSsk-htWc9yZg9eXaIUJwNfTK5oaZOClYKagNC4",{"id":772,"description":773,"extension":737,"hue":16,"meta":774,"name":14,"slug":15,"stem":775,"weight":13,"__hash__":776},"categories\u002Fcategories\u002Faws.json","Hands-on AWS for builders: Lambda, containers and ECR, API Gateway, Step Functions, and the serverless glue in between.",{},"categories\u002Faws","gU2fpFeHDrBz8RJy54lYK7NJxCnMyma_fblrxDoJByQ",{"id":778,"description":779,"extension":737,"hue":54,"meta":780,"name":52,"slug":53,"stem":781,"weight":51,"__hash__":782},"categories\u002Fcategories\u002Fpython.json","Python for people who already build software: a practical, PHP-developer-friendly path into the language and its ecosystem.",{},"categories\u002Fpython","B6ssFzfg4dLAIzOltx3jcPOk7qghiDxoDD74rhlQ9kU",{"id":784,"title":149,"body":785,"category":2243,"date":152,"description":791,"extension":2244,"hasImage":11,"meta":2245,"navigation":11,"path":148,"readTime":10,"seo":2246,"slug":150,"stem":2247,"summary":151,"tagSlugs":2248,"tags":2249,"__hash__":2255},"posts\u002Fposts\u002Fpackage-a-python-lambda-as-a-docker-image.md",{"type":786,"value":787,"toc":2234},"minimark",[788,792,797,805,808,834,837,841,848,1172,1187,1191,1205,1284,1313,1317,1328,1335,1401,1404,1408,1415,1439,1446,1470,1473,1524,1527,1566,1581,1585,1588,1697,1707,1711,1714,1798,1801,1849,1876,1879,2028,2031,2206,2217,2220,2230],[789,790,791],"p",{},"AWS Lambda has a reputation for being all about little zip files, but it has supported Docker container images since 2020, and for a lot of real work they are the better fit. In this series we will build a small but genuinely useful Python function, a thumbnail generator, and take it from a Dockerfile all the way to something you can call over HTTP and even orchestrate into a workflow. This first part is the foundation: package the function as an image, pick an architecture, run it locally, push it to ECR, and invoke it directly.",[793,794,796],"h2",{"id":795},"container-image-or-zip-when-to-reach-for-docker","Container image or zip? When to reach for Docker",[789,798,799,800,804],{},"By default a Lambda is a ",[801,802,803],"code",{},".zip",": your code plus dependencies, uploaded directly or layered on. That path is wonderful for small, pure-Python functions. It supports Lambda layers, editing in the console, and SnapStart for faster cold starts. The catch is size: the deployment package is capped at 50 MB zipped on a direct upload and 250 MB unzipped including layers.",[789,806,807],{},"Container images raise that ceiling to 10 GB and hand you the whole build. Reach for an image when:",[809,810,811,820,831],"ul",{},[812,813,814,815,819],"li",{},"Your dependencies are large (data or machine learning libraries) or need ",[816,817,818],"strong",{},"native system libraries"," (image and video tooling, headless browsers, compiled extensions).",[812,821,822,823,826,827,830],{},"You want your ",[816,824,825],{},"own base image"," and a reproducible ",[801,828,829],{},"docker build",", ideally the same one your CI already produces.",[812,832,833],{},"Your team simply lives in Docker and would rather not learn the zip-and-layers dance.",[789,835,836],{},"The tradeoffs are honest ones: container images do not support SnapStart (that is zip only), and you own patching the base image by rebuilding and redeploying. Our thumbnailer leans on Pillow, which ships native image codecs, so an image is the natural fit and a good excuse to learn the workflow.",[793,838,840],{"id":839},"the-function","The function",[789,842,843,844,847],{},"Here is the whole thing. It takes an image as base64 or a URL, resizes it while preserving aspect ratio, and returns the result as base64 so it travels happily inside JSON. Save it as ",[801,845,846],{},"app.py",".",[849,850,854],"pre",{"className":851,"code":852,"language":53,"meta":853,"style":853},"language-python shiki shiki-themes github-dark github-dark","import base64\nimport io\nfrom urllib.request import urlopen\n\nfrom PIL import Image\n\n\ndef handler(event, context):\n    width = int(event.get(\"width\", 200))\n\n    # Accept either a base64-encoded image or a URL to fetch.\n    if \"image_base64\" in event:\n        raw = base64.b64decode(event[\"image_base64\"])\n    elif \"image_url\" in event:\n        with urlopen(event[\"image_url\"]) as response:\n            raw = response.read()\n    else:\n        raise ValueError(\"Provide image_base64 or image_url\")\n\n    image = Image.open(io.BytesIO(raw))\n    image.thumbnail((width, width))  # resize in place, keeping aspect ratio\n\n    buffer = io.BytesIO()\n    image.save(buffer, format=\"PNG\")\n\n    return {\n        \"width\": image.width,\n        \"height\": image.height,\n        \"thumbnail_base64\": base64.b64encode(buffer.getvalue()).decode(),\n    }\n","",[801,855,856,868,875,888,893,907,911,915,927,954,958,964,978,995,1008,1029,1040,1049,1067,1072,1083,1092,1097,1108,1125,1130,1139,1148,1157,1166],{"__ignoreMap":853},[857,858,860,864],"span",{"class":859,"line":69},"line",[857,861,863],{"class":862},"sOPea","import",[857,865,867],{"class":866},"suv1-"," base64\n",[857,869,870,872],{"class":859,"line":198},[857,871,863],{"class":862},[857,873,874],{"class":866}," io\n",[857,876,877,880,883,885],{"class":859,"line":310},[857,878,879],{"class":862},"from",[857,881,882],{"class":866}," urllib.request ",[857,884,863],{"class":862},[857,886,887],{"class":866}," urlopen\n",[857,889,890],{"class":859,"line":88},[857,891,892],{"emptyLinePlaceholder":11},"\n",[857,894,895,897,901,904],{"class":859,"line":213},[857,896,879],{"class":862},[857,898,900],{"class":899},"s8ozJ"," PIL",[857,902,903],{"class":862}," import",[857,905,906],{"class":866}," Image\n",[857,908,909],{"class":859,"line":167},[857,910,892],{"emptyLinePlaceholder":11},[857,912,913],{"class":859,"line":13},[857,914,892],{"emptyLinePlaceholder":11},[857,916,917,920,924],{"class":859,"line":51},[857,918,919],{"class":862},"def",[857,921,923],{"class":922},"sFR8T"," handler",[857,925,926],{"class":866},"(event, context):\n",[857,928,929,932,935,938,941,945,948,951],{"class":859,"line":67},[857,930,931],{"class":866},"    width ",[857,933,934],{"class":862},"=",[857,936,937],{"class":899}," int",[857,939,940],{"class":866},"(event.get(",[857,942,944],{"class":943},"s4wv1","\"width\"",[857,946,947],{"class":866},", ",[857,949,950],{"class":899},"200",[857,952,953],{"class":866},"))\n",[857,955,956],{"class":859,"line":10},[857,957,892],{"emptyLinePlaceholder":11},[857,959,960],{"class":859,"line":136},[857,961,963],{"class":962},"sJ8bj","    # Accept either a base64-encoded image or a URL to fetch.\n",[857,965,966,969,972,975],{"class":859,"line":49},[857,967,968],{"class":862},"    if",[857,970,971],{"class":943}," \"image_base64\"",[857,973,974],{"class":862}," in",[857,976,977],{"class":866}," event:\n",[857,979,981,984,986,989,992],{"class":859,"line":980},13,[857,982,983],{"class":866},"        raw ",[857,985,934],{"class":862},[857,987,988],{"class":866}," base64.b64decode(event[",[857,990,991],{"class":943},"\"image_base64\"",[857,993,994],{"class":866},"])\n",[857,996,998,1001,1004,1006],{"class":859,"line":997},14,[857,999,1000],{"class":862},"    elif",[857,1002,1003],{"class":943}," \"image_url\"",[857,1005,974],{"class":862},[857,1007,977],{"class":866},[857,1009,1011,1014,1017,1020,1023,1026],{"class":859,"line":1010},15,[857,1012,1013],{"class":862},"        with",[857,1015,1016],{"class":866}," urlopen(event[",[857,1018,1019],{"class":943},"\"image_url\"",[857,1021,1022],{"class":866},"]) ",[857,1024,1025],{"class":862},"as",[857,1027,1028],{"class":866}," response:\n",[857,1030,1032,1035,1037],{"class":859,"line":1031},16,[857,1033,1034],{"class":866},"            raw ",[857,1036,934],{"class":862},[857,1038,1039],{"class":866}," response.read()\n",[857,1041,1043,1046],{"class":859,"line":1042},17,[857,1044,1045],{"class":862},"    else",[857,1047,1048],{"class":866},":\n",[857,1050,1052,1055,1058,1061,1064],{"class":859,"line":1051},18,[857,1053,1054],{"class":862},"        raise",[857,1056,1057],{"class":899}," ValueError",[857,1059,1060],{"class":866},"(",[857,1062,1063],{"class":943},"\"Provide image_base64 or image_url\"",[857,1065,1066],{"class":866},")\n",[857,1068,1070],{"class":859,"line":1069},19,[857,1071,892],{"emptyLinePlaceholder":11},[857,1073,1075,1078,1080],{"class":859,"line":1074},20,[857,1076,1077],{"class":866},"    image ",[857,1079,934],{"class":862},[857,1081,1082],{"class":866}," Image.open(io.BytesIO(raw))\n",[857,1084,1086,1089],{"class":859,"line":1085},21,[857,1087,1088],{"class":866},"    image.thumbnail((width, width))  ",[857,1090,1091],{"class":962},"# resize in place, keeping aspect ratio\n",[857,1093,1095],{"class":859,"line":1094},22,[857,1096,892],{"emptyLinePlaceholder":11},[857,1098,1100,1103,1105],{"class":859,"line":1099},23,[857,1101,1102],{"class":866},"    buffer ",[857,1104,934],{"class":862},[857,1106,1107],{"class":866}," io.BytesIO()\n",[857,1109,1111,1114,1118,1120,1123],{"class":859,"line":1110},24,[857,1112,1113],{"class":866},"    image.save(buffer, ",[857,1115,1117],{"class":1116},"s-3mD","format",[857,1119,934],{"class":862},[857,1121,1122],{"class":943},"\"PNG\"",[857,1124,1066],{"class":866},[857,1126,1128],{"class":859,"line":1127},25,[857,1129,892],{"emptyLinePlaceholder":11},[857,1131,1133,1136],{"class":859,"line":1132},26,[857,1134,1135],{"class":862},"    return",[857,1137,1138],{"class":866}," {\n",[857,1140,1142,1145],{"class":859,"line":1141},27,[857,1143,1144],{"class":943},"        \"width\"",[857,1146,1147],{"class":866},": image.width,\n",[857,1149,1151,1154],{"class":859,"line":1150},28,[857,1152,1153],{"class":943},"        \"height\"",[857,1155,1156],{"class":866},": image.height,\n",[857,1158,1160,1163],{"class":859,"line":1159},29,[857,1161,1162],{"class":943},"        \"thumbnail_base64\"",[857,1164,1165],{"class":866},": base64.b64encode(buffer.getvalue()).decode(),\n",[857,1167,1169],{"class":859,"line":1168},30,[857,1170,1171],{"class":866},"    }\n",[789,1173,1174,1175,1178,1179,1182,1183,1186],{},"A Lambda handler is just a function that takes ",[801,1176,1177],{},"(event, context)",". The ",[801,1180,1181],{},"event"," is whatever invoked it sends; the ",[801,1184,1185],{},"context"," carries runtime metadata. Everything else here is ordinary Python, which is exactly the point.",[793,1188,1190],{"id":1189},"the-dockerfile","The Dockerfile",[789,1192,1193,1194,1197,1198,1201,1202,1204],{},"AWS publishes base images that already speak the Lambda Runtime API, so the Dockerfile is short. Put ",[801,1195,1196],{},"Pillow"," in a ",[801,1199,1200],{},"requirements.txt"," next to ",[801,1203,846],{},", then:",[849,1206,1210],{"className":1207,"code":1208,"language":1209,"meta":853,"style":853},"language-dockerfile shiki shiki-themes github-dark github-dark","FROM public.ecr.aws\u002Flambda\u002Fpython:3.13\n\n# Dependencies first, so Docker can cache this layer between builds.\nCOPY requirements.txt ${LAMBDA_TASK_ROOT}\u002F\nRUN pip install --no-cache-dir -r requirements.txt\n\n# Then the function code.\nCOPY app.py ${LAMBDA_TASK_ROOT}\u002F\n\n# \"module.function\" is the handler() in app.py.\nCMD [\"app.handler\"]\n","dockerfile",[801,1211,1212,1220,1224,1229,1237,1245,1249,1254,1261,1265,1270],{"__ignoreMap":853},[857,1213,1214,1217],{"class":859,"line":69},[857,1215,1216],{"class":862},"FROM",[857,1218,1219],{"class":866}," public.ecr.aws\u002Flambda\u002Fpython:3.13\n",[857,1221,1222],{"class":859,"line":198},[857,1223,892],{"emptyLinePlaceholder":11},[857,1225,1226],{"class":859,"line":310},[857,1227,1228],{"class":962},"# Dependencies first, so Docker can cache this layer between builds.\n",[857,1230,1231,1234],{"class":859,"line":88},[857,1232,1233],{"class":862},"COPY",[857,1235,1236],{"class":866}," requirements.txt ${LAMBDA_TASK_ROOT}\u002F\n",[857,1238,1239,1242],{"class":859,"line":213},[857,1240,1241],{"class":862},"RUN",[857,1243,1244],{"class":866}," pip install --no-cache-dir -r requirements.txt\n",[857,1246,1247],{"class":859,"line":167},[857,1248,892],{"emptyLinePlaceholder":11},[857,1250,1251],{"class":859,"line":13},[857,1252,1253],{"class":962},"# Then the function code.\n",[857,1255,1256,1258],{"class":859,"line":51},[857,1257,1233],{"class":862},[857,1259,1260],{"class":866}," app.py ${LAMBDA_TASK_ROOT}\u002F\n",[857,1262,1263],{"class":859,"line":67},[857,1264,892],{"emptyLinePlaceholder":11},[857,1266,1267],{"class":859,"line":10},[857,1268,1269],{"class":962},"# \"module.function\" is the handler() in app.py.\n",[857,1271,1272,1275,1278,1281],{"class":859,"line":136},[857,1273,1274],{"class":862},"CMD",[857,1276,1277],{"class":866}," [",[857,1279,1280],{"class":943},"\"app.handler\"",[857,1282,1283],{"class":866},"]\n",[789,1285,1286,1289,1290,1293,1294,1297,1298,1300,1301,1304,1305,1308,1309,1312],{},[801,1287,1288],{},"${LAMBDA_TASK_ROOT}"," is ",[801,1291,1292],{},"\u002Fvar\u002Ftask",", where Lambda looks for your code. The base image already sets the ",[801,1295,1296],{},"ENTRYPOINT"," to its runtime bootstrap, so you only supply the handler name as the ",[801,1299,1274],{},". Do not override the entrypoint or add a ",[801,1302,1303],{},"USER","; Lambda manages that for you. The ",[801,1306,1307],{},"3.13"," tag is a solid default (Python 3.13 on Amazon Linux 2023); ",[801,1310,1311],{},"3.14"," is the newest if you want the latest, and both run on either CPU architecture.",[793,1314,1316],{"id":1315},"arm64-or-x86_64","arm64 or x86_64?",[789,1318,1319,1320,1327],{},"Lambda runs on two architectures: x86_64 (the default) and arm64, which is AWS Graviton2. AWS quotes ",[1321,1322,1326],"a",{"href":1323,"rel":1324},"https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Faws\u002Faws-lambda-functions-powered-by-aws-graviton2-processor-run-your-functions-on-arm-and-get-up-to-34-better-price-performance\u002F",[1325],"nofollow","up to 34% better price performance"," on arm64 along with a lower per-millisecond price, so arm64 is the sensible default unless something stops you.",[789,1329,1330,1331,1334],{},"With containers there is one rule to internalize: ",[816,1332,1333],{},"an image is built for exactly one architecture",", and the function's architecture has to match it. Every native dependency has to have an arm64 build too. Pillow does, as do almost all popular packages now, but it is the thing to check before you switch. You select the architecture at build time:",[849,1336,1340],{"className":1337,"code":1338,"language":1339,"meta":853,"style":853},"language-bash shiki shiki-themes github-dark github-dark","# Recommended default: arm64 (Graviton)\ndocker buildx build --platform linux\u002Farm64 -t thumbnailer:arm64 .\n\n# Or x86_64, if a dependency forces your hand\ndocker buildx build --platform linux\u002Famd64 -t thumbnailer:amd64 .\n","bash",[801,1341,1342,1347,1372,1376,1381],{"__ignoreMap":853},[857,1343,1344],{"class":859,"line":69},[857,1345,1346],{"class":962},"# Recommended default: arm64 (Graviton)\n",[857,1348,1349,1351,1354,1357,1360,1363,1366,1369],{"class":859,"line":198},[857,1350,24],{"class":922},[857,1352,1353],{"class":943}," buildx",[857,1355,1356],{"class":943}," build",[857,1358,1359],{"class":899}," --platform",[857,1361,1362],{"class":943}," linux\u002Farm64",[857,1364,1365],{"class":899}," -t",[857,1367,1368],{"class":943}," thumbnailer:arm64",[857,1370,1371],{"class":943}," .\n",[857,1373,1374],{"class":859,"line":310},[857,1375,892],{"emptyLinePlaceholder":11},[857,1377,1378],{"class":859,"line":88},[857,1379,1380],{"class":962},"# Or x86_64, if a dependency forces your hand\n",[857,1382,1383,1385,1387,1389,1391,1394,1396,1399],{"class":859,"line":213},[857,1384,24],{"class":922},[857,1386,1353],{"class":943},[857,1388,1356],{"class":943},[857,1390,1359],{"class":899},[857,1392,1393],{"class":943}," linux\u002Famd64",[857,1395,1365],{"class":899},[857,1397,1398],{"class":943}," thumbnailer:amd64",[857,1400,1371],{"class":943},[789,1402,1403],{},"If you are on an Apple Silicon Mac, arm64 is also your native build, so it is both the faster thing to build locally and the cheaper thing to run. A happy alignment.",[793,1405,1407],{"id":1406},"run-it-locally-with-the-runtime-interface-emulator","Run it locally with the Runtime Interface Emulator",[789,1409,1410,1411,1414],{},"This is the part people miss: the AWS base images bundle the ",[816,1412,1413],{},"Runtime Interface Emulator"," (RIE), a tiny local stand-in for the Lambda service. Start the container and it listens like the real thing:",[849,1416,1418],{"className":1337,"code":1417,"language":1339,"meta":853,"style":853},"docker run --rm -p 9000:8080 thumbnailer:arm64\n",[801,1419,1420],{"__ignoreMap":853},[857,1421,1422,1424,1427,1430,1433,1436],{"class":859,"line":69},[857,1423,24],{"class":922},[857,1425,1426],{"class":943}," run",[857,1428,1429],{"class":899}," --rm",[857,1431,1432],{"class":899}," -p",[857,1434,1435],{"class":943}," 9000:8080",[857,1437,1438],{"class":943}," thumbnailer:arm64\n",[789,1440,1441,1442,1445],{},"Then, in another terminal, post an event to the emulator's invocation endpoint. That URL is fixed; the literal word ",[801,1443,1444],{},"function"," is part of it and the emulator ignores the function name:",[849,1447,1449],{"className":1337,"code":1448,"language":1339,"meta":853,"style":853},"curl \"http:\u002F\u002Flocalhost:9000\u002F2015-03-31\u002Ffunctions\u002Ffunction\u002Finvocations\" \\\n  -d '{\"image_url\": \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fjpeg\", \"width\": 120}'\n",[801,1450,1451,1462],{"__ignoreMap":853},[857,1452,1453,1456,1459],{"class":859,"line":69},[857,1454,1455],{"class":922},"curl",[857,1457,1458],{"class":943}," \"http:\u002F\u002Flocalhost:9000\u002F2015-03-31\u002Ffunctions\u002Ffunction\u002Finvocations\"",[857,1460,1461],{"class":899}," \\\n",[857,1463,1464,1467],{"class":859,"line":198},[857,1465,1466],{"class":899},"  -d",[857,1468,1469],{"class":943}," '{\"image_url\": \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fjpeg\", \"width\": 120}'\n",[789,1471,1472],{},"You get back the handler's return value as JSON:",[849,1474,1477],{"className":1475,"code":1476,"language":737,"meta":853,"style":853},"language-json shiki shiki-themes github-dark github-dark","{\n  \"width\": 120,\n  \"height\": 120,\n  \"thumbnail_base64\": \"iVBORw0KGgo...\"\n}\n",[801,1478,1479,1484,1498,1509,1519],{"__ignoreMap":853},[857,1480,1481],{"class":859,"line":69},[857,1482,1483],{"class":866},"{\n",[857,1485,1486,1489,1492,1495],{"class":859,"line":198},[857,1487,1488],{"class":899},"  \"width\"",[857,1490,1491],{"class":866},": ",[857,1493,1494],{"class":899},"120",[857,1496,1497],{"class":866},",\n",[857,1499,1500,1503,1505,1507],{"class":859,"line":310},[857,1501,1502],{"class":899},"  \"height\"",[857,1504,1491],{"class":866},[857,1506,1494],{"class":899},[857,1508,1497],{"class":866},[857,1510,1511,1514,1516],{"class":859,"line":88},[857,1512,1513],{"class":899},"  \"thumbnail_base64\"",[857,1515,1491],{"class":866},[857,1517,1518],{"class":943},"\"iVBORw0KGgo...\"\n",[857,1520,1521],{"class":859,"line":213},[857,1522,1523],{"class":866},"}\n",[789,1525,1526],{},"To actually see the thumbnail, decode that field to a file:",[849,1528,1530],{"className":1337,"code":1529,"language":1339,"meta":853,"style":853},"curl -s \"http:\u002F\u002Flocalhost:9000\u002F2015-03-31\u002Ffunctions\u002Ffunction\u002Finvocations\" \\\n  -d '{\"image_url\": \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fjpeg\", \"width\": 120}' \\\n  | python3 -c \"import sys, json, base64; open('thumb.png', 'wb').write(base64.b64decode(json.load(sys.stdin)['thumbnail_base64']))\"\n",[801,1531,1532,1543,1552],{"__ignoreMap":853},[857,1533,1534,1536,1539,1541],{"class":859,"line":69},[857,1535,1455],{"class":922},[857,1537,1538],{"class":899}," -s",[857,1540,1458],{"class":943},[857,1542,1461],{"class":899},[857,1544,1545,1547,1550],{"class":859,"line":198},[857,1546,1466],{"class":899},[857,1548,1549],{"class":943}," '{\"image_url\": \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fjpeg\", \"width\": 120}'",[857,1551,1461],{"class":899},[857,1553,1554,1557,1560,1563],{"class":859,"line":310},[857,1555,1556],{"class":862},"  |",[857,1558,1559],{"class":922}," python3",[857,1561,1562],{"class":899}," -c",[857,1564,1565],{"class":943}," \"import sys, json, base64; open('thumb.png', 'wb').write(base64.b64decode(json.load(sys.stdin)['thumbnail_base64']))\"\n",[789,1567,1568,1569,1572,1573,1576,1577,1580],{},"Open ",[801,1570,1571],{},"thumb.png"," and there is your resized image, produced by the exact bytes you are about to ship. (One gotcha: if you built an arm64 image but are running on an x86 host, add ",[801,1574,1575],{},"--platform linux\u002Farm64"," to the ",[801,1578,1579],{},"docker run"," so it emulates the right CPU.)",[793,1582,1584],{"id":1583},"push-the-image-to-amazon-ecr","Push the image to Amazon ECR",[789,1586,1587],{},"Lambda pulls container images from Amazon Elastic Container Registry, in the same Region as the function. Three steps: create a repository, log Docker in, then tag and push.",[849,1589,1591],{"className":1337,"code":1590,"language":1339,"meta":853,"style":853},"# 1. Create the repository (once per repo)\naws ecr create-repository --repository-name thumbnailer --region us-east-1\n\n# 2. Authenticate Docker to your private registry\naws ecr get-login-password --region us-east-1 \\\n  | docker login --username AWS --password-stdin 111122223333.dkr.ecr.us-east-1.amazonaws.com\n\n# 3. Tag the local image with the registry URI and push it\ndocker tag thumbnailer:arm64 111122223333.dkr.ecr.us-east-1.amazonaws.com\u002Fthumbnailer:latest\ndocker push 111122223333.dkr.ecr.us-east-1.amazonaws.com\u002Fthumbnailer:latest\n",[801,1592,1593,1598,1620,1624,1629,1645,1667,1671,1676,1688],{"__ignoreMap":853},[857,1594,1595],{"class":859,"line":69},[857,1596,1597],{"class":962},"# 1. Create the repository (once per repo)\n",[857,1599,1600,1602,1605,1608,1611,1614,1617],{"class":859,"line":198},[857,1601,15],{"class":922},[857,1603,1604],{"class":943}," ecr",[857,1606,1607],{"class":943}," create-repository",[857,1609,1610],{"class":899}," --repository-name",[857,1612,1613],{"class":943}," thumbnailer",[857,1615,1616],{"class":899}," --region",[857,1618,1619],{"class":943}," us-east-1\n",[857,1621,1622],{"class":859,"line":310},[857,1623,892],{"emptyLinePlaceholder":11},[857,1625,1626],{"class":859,"line":88},[857,1627,1628],{"class":962},"# 2. Authenticate Docker to your private registry\n",[857,1630,1631,1633,1635,1638,1640,1643],{"class":859,"line":213},[857,1632,15],{"class":922},[857,1634,1604],{"class":943},[857,1636,1637],{"class":943}," get-login-password",[857,1639,1616],{"class":899},[857,1641,1642],{"class":943}," us-east-1",[857,1644,1461],{"class":899},[857,1646,1647,1649,1652,1655,1658,1661,1664],{"class":859,"line":167},[857,1648,1556],{"class":862},[857,1650,1651],{"class":922}," docker",[857,1653,1654],{"class":943}," login",[857,1656,1657],{"class":899}," --username",[857,1659,1660],{"class":943}," AWS",[857,1662,1663],{"class":899}," --password-stdin",[857,1665,1666],{"class":943}," 111122223333.dkr.ecr.us-east-1.amazonaws.com\n",[857,1668,1669],{"class":859,"line":13},[857,1670,892],{"emptyLinePlaceholder":11},[857,1672,1673],{"class":859,"line":51},[857,1674,1675],{"class":962},"# 3. Tag the local image with the registry URI and push it\n",[857,1677,1678,1680,1683,1685],{"class":859,"line":67},[857,1679,24],{"class":922},[857,1681,1682],{"class":943}," tag",[857,1684,1368],{"class":943},[857,1686,1687],{"class":943}," 111122223333.dkr.ecr.us-east-1.amazonaws.com\u002Fthumbnailer:latest\n",[857,1689,1690,1692,1695],{"class":859,"line":10},[857,1691,24],{"class":922},[857,1693,1694],{"class":943}," push",[857,1696,1687],{"class":943},[789,1698,1699,1700,1703,1704,847],{},"Swap ",[801,1701,1702],{},"111122223333"," for your AWS account ID. The registry URI follows the pattern ",[801,1705,1706],{},"\u003Caccount>.dkr.ecr.\u003Cregion>.amazonaws.com\u002F\u003Crepo>:\u003Ctag>",[793,1708,1710],{"id":1709},"create-the-function-and-invoke-it-directly","Create the function and invoke it directly",[789,1712,1713],{},"With the image in ECR, create the function from it. You need an execution role; a basic one that allows writing logs is enough to start.",[849,1715,1717],{"className":1337,"code":1716,"language":1339,"meta":853,"style":853},"aws lambda create-function \\\n  --function-name thumbnailer \\\n  --package-type Image \\\n  --code ImageUri=111122223333.dkr.ecr.us-east-1.amazonaws.com\u002Fthumbnailer:latest \\\n  --role arn:aws:iam::111122223333:role\u002Flambda-thumbnailer-role \\\n  --architectures arm64 \\\n  --memory-size 512 \\\n  --timeout 30\n",[801,1718,1719,1731,1740,1750,1760,1770,1780,1790],{"__ignoreMap":853},[857,1720,1721,1723,1726,1729],{"class":859,"line":69},[857,1722,15],{"class":922},[857,1724,1725],{"class":943}," lambda",[857,1727,1728],{"class":943}," create-function",[857,1730,1461],{"class":899},[857,1732,1733,1736,1738],{"class":859,"line":198},[857,1734,1735],{"class":899},"  --function-name",[857,1737,1613],{"class":943},[857,1739,1461],{"class":899},[857,1741,1742,1745,1748],{"class":859,"line":310},[857,1743,1744],{"class":899},"  --package-type",[857,1746,1747],{"class":943}," Image",[857,1749,1461],{"class":899},[857,1751,1752,1755,1758],{"class":859,"line":88},[857,1753,1754],{"class":899},"  --code",[857,1756,1757],{"class":943}," ImageUri=111122223333.dkr.ecr.us-east-1.amazonaws.com\u002Fthumbnailer:latest",[857,1759,1461],{"class":899},[857,1761,1762,1765,1768],{"class":859,"line":213},[857,1763,1764],{"class":899},"  --role",[857,1766,1767],{"class":943}," arn:aws:iam::111122223333:role\u002Flambda-thumbnailer-role",[857,1769,1461],{"class":899},[857,1771,1772,1775,1778],{"class":859,"line":167},[857,1773,1774],{"class":899},"  --architectures",[857,1776,1777],{"class":943}," arm64",[857,1779,1461],{"class":899},[857,1781,1782,1785,1788],{"class":859,"line":13},[857,1783,1784],{"class":899},"  --memory-size",[857,1786,1787],{"class":899}," 512",[857,1789,1461],{"class":899},[857,1791,1792,1795],{"class":859,"line":51},[857,1793,1794],{"class":899},"  --timeout",[857,1796,1797],{"class":899}," 30\n",[789,1799,1800],{},"Now invoke it. No API Gateway, no HTTP, just the Lambda API directly, which is perfect for internal tools and scripts:",[849,1802,1804],{"className":1337,"code":1803,"language":1339,"meta":853,"style":853},"aws lambda invoke \\\n  --function-name thumbnailer \\\n  --cli-binary-format raw-in-base64-out \\\n  --payload '{\"image_url\": \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fjpeg\", \"width\": 120}' \\\n  response.json\n",[801,1805,1806,1817,1825,1835,1844],{"__ignoreMap":853},[857,1807,1808,1810,1812,1815],{"class":859,"line":69},[857,1809,15],{"class":922},[857,1811,1725],{"class":943},[857,1813,1814],{"class":943}," invoke",[857,1816,1461],{"class":899},[857,1818,1819,1821,1823],{"class":859,"line":198},[857,1820,1735],{"class":899},[857,1822,1613],{"class":943},[857,1824,1461],{"class":899},[857,1826,1827,1830,1833],{"class":859,"line":310},[857,1828,1829],{"class":899},"  --cli-binary-format",[857,1831,1832],{"class":943}," raw-in-base64-out",[857,1834,1461],{"class":899},[857,1836,1837,1840,1842],{"class":859,"line":88},[857,1838,1839],{"class":899},"  --payload",[857,1841,1549],{"class":943},[857,1843,1461],{"class":899},[857,1845,1846],{"class":859,"line":213},[857,1847,1848],{"class":943},"  response.json\n",[789,1850,1851,1852,1855,1856,1859,1860,1863,1864,1867,1868,1871,1872,1875],{},"The ",[801,1853,1854],{},"--cli-binary-format raw-in-base64-out"," flag is required on AWS CLI v2 when you pass an inline JSON payload. The command prints ",[801,1857,1858],{},"{\"ExecutedVersion\": \"$LATEST\", \"StatusCode\": 200}"," and writes the function's output to ",[801,1861,1862],{},"response.json",". One sharp edge worth knowing: ",[801,1865,1866],{},"StatusCode"," is 200 even when your code throws. A handler error shows up as a ",[801,1869,1870],{},"FunctionError"," field instead, and ",[801,1873,1874],{},"--log-type Tail"," returns the logs so you can see what happened.",[789,1877,1878],{},"From application code it is the same idea. In Python with boto3:",[849,1880,1882],{"className":851,"code":1881,"language":53,"meta":853,"style":853},"import json\nimport boto3\n\nlambda_client = boto3.client(\"lambda\")\n\nresponse = lambda_client.invoke(\n    FunctionName=\"thumbnailer\",\n    InvocationType=\"RequestResponse\",  # synchronous; use \"Event\" to fire and forget\n    Payload=json.dumps({\"image_url\": \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fjpeg\", \"width\": 120}),\n)\n\nresult = json.load(response[\"Payload\"])\nprint(result[\"width\"], result[\"height\"])\n",[801,1883,1884,1891,1898,1902,1917,1921,1931,1943,1959,1987,1991,1995,2010],{"__ignoreMap":853},[857,1885,1886,1888],{"class":859,"line":69},[857,1887,863],{"class":862},[857,1889,1890],{"class":866}," json\n",[857,1892,1893,1895],{"class":859,"line":198},[857,1894,863],{"class":862},[857,1896,1897],{"class":866}," boto3\n",[857,1899,1900],{"class":859,"line":310},[857,1901,892],{"emptyLinePlaceholder":11},[857,1903,1904,1907,1909,1912,1915],{"class":859,"line":88},[857,1905,1906],{"class":866},"lambda_client ",[857,1908,934],{"class":862},[857,1910,1911],{"class":866}," boto3.client(",[857,1913,1914],{"class":943},"\"lambda\"",[857,1916,1066],{"class":866},[857,1918,1919],{"class":859,"line":213},[857,1920,892],{"emptyLinePlaceholder":11},[857,1922,1923,1926,1928],{"class":859,"line":167},[857,1924,1925],{"class":866},"response ",[857,1927,934],{"class":862},[857,1929,1930],{"class":866}," lambda_client.invoke(\n",[857,1932,1933,1936,1938,1941],{"class":859,"line":13},[857,1934,1935],{"class":1116},"    FunctionName",[857,1937,934],{"class":862},[857,1939,1940],{"class":943},"\"thumbnailer\"",[857,1942,1497],{"class":866},[857,1944,1945,1948,1950,1953,1956],{"class":859,"line":51},[857,1946,1947],{"class":1116},"    InvocationType",[857,1949,934],{"class":862},[857,1951,1952],{"class":943},"\"RequestResponse\"",[857,1954,1955],{"class":866},",  ",[857,1957,1958],{"class":962},"# synchronous; use \"Event\" to fire and forget\n",[857,1960,1961,1964,1966,1969,1971,1973,1976,1978,1980,1982,1984],{"class":859,"line":67},[857,1962,1963],{"class":1116},"    Payload",[857,1965,934],{"class":862},[857,1967,1968],{"class":866},"json.dumps({",[857,1970,1019],{"class":943},[857,1972,1491],{"class":866},[857,1974,1975],{"class":943},"\"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fjpeg\"",[857,1977,947],{"class":866},[857,1979,944],{"class":943},[857,1981,1491],{"class":866},[857,1983,1494],{"class":899},[857,1985,1986],{"class":866},"}),\n",[857,1988,1989],{"class":859,"line":10},[857,1990,1066],{"class":866},[857,1992,1993],{"class":859,"line":136},[857,1994,892],{"emptyLinePlaceholder":11},[857,1996,1997,2000,2002,2005,2008],{"class":859,"line":49},[857,1998,1999],{"class":866},"result ",[857,2001,934],{"class":862},[857,2003,2004],{"class":866}," json.load(response[",[857,2006,2007],{"class":943},"\"Payload\"",[857,2009,994],{"class":866},[857,2011,2012,2015,2018,2020,2023,2026],{"class":859,"line":980},[857,2013,2014],{"class":899},"print",[857,2016,2017],{"class":866},"(result[",[857,2019,944],{"class":943},[857,2021,2022],{"class":866},"], result[",[857,2024,2025],{"class":943},"\"height\"",[857,2027,994],{"class":866},[789,2029,2030],{},"And because this is a PHP blog at heart, the AWS SDK for PHP does it just as cleanly. We will wire this into a real Laravel app in part two, but the call itself is a few lines:",[849,2032,2035],{"className":2033,"code":2034,"language":59,"meta":853,"style":853},"language-php shiki shiki-themes github-dark github-dark","use Aws\\Lambda\\LambdaClient;\n\n$lambda = new LambdaClient(['region' => 'us-east-1', 'version' => 'latest']);\n\n$result = $lambda->invoke([\n    'FunctionName' => 'thumbnailer',\n    'Payload' => json_encode(['image_url' => 'https:\u002F\u002Fexample.com\u002Fcat.jpg', 'width' => 120]),\n]);\n\n$thumbnail = json_decode($result->get('Payload')->getContents(), true);\n",[801,2036,2037,2048,2052,2090,2094,2113,2125,2158,2162,2166],{"__ignoreMap":853},[857,2038,2039,2042,2045],{"class":859,"line":69},[857,2040,2041],{"class":862},"use",[857,2043,2044],{"class":899}," Aws\\Lambda\\LambdaClient",[857,2046,2047],{"class":866},";\n",[857,2049,2050],{"class":859,"line":198},[857,2051,892],{"emptyLinePlaceholder":11},[857,2053,2054,2057,2059,2062,2065,2068,2071,2074,2077,2079,2082,2084,2087],{"class":859,"line":310},[857,2055,2056],{"class":866},"$lambda ",[857,2058,934],{"class":862},[857,2060,2061],{"class":862}," new",[857,2063,2064],{"class":899}," LambdaClient",[857,2066,2067],{"class":866},"([",[857,2069,2070],{"class":943},"'region'",[857,2072,2073],{"class":862}," =>",[857,2075,2076],{"class":943}," 'us-east-1'",[857,2078,947],{"class":866},[857,2080,2081],{"class":943},"'version'",[857,2083,2073],{"class":862},[857,2085,2086],{"class":943}," 'latest'",[857,2088,2089],{"class":866},"]);\n",[857,2091,2092],{"class":859,"line":88},[857,2093,892],{"emptyLinePlaceholder":11},[857,2095,2096,2099,2101,2104,2107,2110],{"class":859,"line":213},[857,2097,2098],{"class":866},"$result ",[857,2100,934],{"class":862},[857,2102,2103],{"class":866}," $lambda",[857,2105,2106],{"class":862},"->",[857,2108,2109],{"class":922},"invoke",[857,2111,2112],{"class":866},"([\n",[857,2114,2115,2118,2120,2123],{"class":859,"line":167},[857,2116,2117],{"class":943},"    'FunctionName'",[857,2119,2073],{"class":862},[857,2121,2122],{"class":943}," 'thumbnailer'",[857,2124,1497],{"class":866},[857,2126,2127,2130,2132,2135,2137,2140,2142,2145,2147,2150,2152,2155],{"class":859,"line":13},[857,2128,2129],{"class":943},"    'Payload'",[857,2131,2073],{"class":862},[857,2133,2134],{"class":899}," json_encode",[857,2136,2067],{"class":866},[857,2138,2139],{"class":943},"'image_url'",[857,2141,2073],{"class":862},[857,2143,2144],{"class":943}," 'https:\u002F\u002Fexample.com\u002Fcat.jpg'",[857,2146,947],{"class":866},[857,2148,2149],{"class":943},"'width'",[857,2151,2073],{"class":862},[857,2153,2154],{"class":899}," 120",[857,2156,2157],{"class":866},"]),\n",[857,2159,2160],{"class":859,"line":51},[857,2161,2089],{"class":866},[857,2163,2164],{"class":859,"line":67},[857,2165,892],{"emptyLinePlaceholder":11},[857,2167,2168,2171,2173,2176,2179,2181,2184,2186,2189,2192,2194,2197,2200,2203],{"class":859,"line":10},[857,2169,2170],{"class":866},"$thumbnail ",[857,2172,934],{"class":862},[857,2174,2175],{"class":899}," json_decode",[857,2177,2178],{"class":866},"($result",[857,2180,2106],{"class":862},[857,2182,2183],{"class":922},"get",[857,2185,1060],{"class":866},[857,2187,2188],{"class":943},"'Payload'",[857,2190,2191],{"class":866},")",[857,2193,2106],{"class":862},[857,2195,2196],{"class":922},"getContents",[857,2198,2199],{"class":866},"(), ",[857,2201,2202],{"class":899},"true",[857,2204,2205],{"class":866},");\n",[789,2207,2208,2209,2212,2213,2216],{},"After you change the code, rebuild the image, push it, and tell Lambda to pick up the new version with ",[801,2210,2211],{},"aws lambda update-function-code --function-name thumbnailer --image-uri ...:latest --publish",". Lambda resolves a tag to a specific image digest at deploy time, so pushing a new ",[801,2214,2215],{},":latest"," does not update the function on its own; the update command is what does it.",[789,2218,2219],{},"You now have a containerized Python function tested locally with the very same emulator AWS runs, living in ECR, and callable directly. Invoking by hand or from a script is great for internal and event-driven use, but if you want a real URL that the world can hit, you need a front door. That is part two, where we compare Lambda function URLs against API Gateway and then call the result from a Laravel app.",[2221,2222,2224],"note",{"label":2223},"AWS Lambda series",[789,2225,2226,2227],{},"This is part one of a hands-on series on running containerized Lambdas.\nNext: ",[1321,2228,132],{"href":2229},"\u002Farticles\u002Fgive-your-lambda-an-http-front-door",[2231,2232,2233],"style",{},"html pre.shiki code .sOPea, html code.shiki .sOPea{--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .suv1-, html code.shiki .suv1-{--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .s8ozJ, html code.shiki .s8ozJ{--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .sFR8T, html code.shiki .sFR8T{--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .s4wv1, html code.shiki .s4wv1{--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .s-3mD, html code.shiki .s-3mD{--shiki-default:#FFAB70;--shiki-dark:#FFAB70}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":853,"searchDepth":198,"depth":198,"links":2235},[2236,2237,2238,2239,2240,2241,2242],{"id":795,"depth":198,"text":796},{"id":839,"depth":198,"text":840},{"id":1189,"depth":198,"text":1190},{"id":1315,"depth":198,"text":1316},{"id":1406,"depth":198,"text":1407},{"id":1583,"depth":198,"text":1584},{"id":1709,"depth":198,"text":1710},{"id":13,"name":14,"slug":15,"hue":16},"md",{},{"title":149,"description":791},"posts\u002Fpackage-a-python-lambda-as-a-docker-image",[15,21,24,40,128],[2250,2251,2252,2253,2254],{"name":14,"slug":15},{"name":20,"slug":21},{"name":23,"slug":24},{"name":39,"slug":40},{"name":127,"slug":128},"L9RCidInpvX8wvjKiAcB2IInAfz70gmVyPHlts7QIlU",1781531464119]