


Go to your lambda and select Lambda layer (presumably, the API Gateway layer was selected instead).This is an endpoint of your Static website hosting, and it is http, not https. At this state, before clicking on Save, copy your Endpoint.YOUR_BUCKET -> Permissions -> Bucket policy and paste.YOUR_BUCKET -> Permissions -> Block public access -> Edit, uncheck Block all public access, Save -> Confirm.Having an API endpoint, go to your bucket created at the beginning and add permissions.Now if you click on API Gateway, you should see API endpoint, something like.In Security, select Open, then click Add.You can select api that has prefix -API or Create a new API.YOUR_LAMBDA -> Add trigger -> API Gateway.After clicking on Create function, the lambda should be created.Īdd a trigger, which will listen to http requests.Select Use an existing role and choose your role in the list, update the list if necessary.Now you are again on the lambda creating page.Click on Create role you can close the tab.Click on Next: tags -> Next: Review, name your role, for example, "access_to_putObject_role".Select your policy clicking on the checkbox.On the previous tab, update the policy list clicking on the button with reload image or reloading the page.Name your policy, for example: "access_to_putObject_policy" and click on Create policy you can close the tab.on that tab, you can use Visual Editor or add this JSON.then Create role -> Lambda -> Next: Permissions -> Create policy, a new tab should open.There should be a link to IAM console, go to there.You can edit it later or you can create and set up a role right now. If you click on Create function, a default role will be created. You need a role that has permission to put objects to your storage (aka policy).Select the latest version of Node.js according to Releases (you can change it later).Create a function -> Author from scratch.Then we should set up all the permissions and redirection rules. Setting up To resize images we need a storage, which is S3 (but could be CloudFront), and Lambda function.

You can read about withoutEnlargement method. Note that s3-resizer does not enlarge an image if the original image width or height are less than the requested dimensions. Instead of WxH there're some extra available magic paths: We'll obviously have a new image next time. So, if there's not image in this path, it's redirected to lambda and, after a moment, lambda creates the suitable image and then redirects back. To resize on fly this image to, say, 150x150, we can make a request like this: Let's say we have some shared image in S3, for example: It's AWS Lambda, which is a compute service that lets you run code without provisioning or managing servers.
