# How to automatically resize images with serverless

**URL:** <https://discourse.sst.dev/t/how-to-automatically-resize-images-with-serverless/2399>\
**Category:** Chapter Comments\
**Created:** [May 21, 2021, 8:52pm UTC](https://discourse.sst.dev/t/how-to-automatically-resize-images-with-serverless/2399 "2021-05-21T20:52:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [May 21, 2021, 8:52pm UTC](https://discourse.sst.dev/t/how-to-automatically-resize-images-with-serverless/2399/1 "2021-05-21T20:52:31Z")

</div>

Link to chapter — [https://serverless-stack.com/examples/how-to-automatically-resize-images-with-serverless.html](https://serverless-stack.com/examples/how-to-automatically-resize-images-with-serverless.html)

---

<div class="post-metadata">

**Author:** ![gregdalzotto](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/gregdalzotto/32/1235_2.png) [@gregdalzotto](https://discourse.sst.dev/u/gregdalzotto)\
**Post date:** [October 18, 2021, 8:58pm UTC](https://discourse.sst.dev/t/how-to-automatically-resize-images-with-serverless/2399/2 "2021-10-18T20:58:36Z")

</div>

Nice! Works, but I have a doubt.

Is it possible to use the created buckets with **CloudFront**? I tried but the return is Access Denied. Any suggestion? Thanks!

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [October 18, 2021, 9:20pm UTC](https://discourse.sst.dev/t/how-to-automatically-resize-images-with-serverless/2399/3 "2021-10-18T21:20:36Z")

</div>

You mean attaching a CloudFront distribution to the S3 bucket?

---

<div class="post-metadata">

**Author:** ![gregdalzotto](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/gregdalzotto/32/1235_2.png) [@gregdalzotto](https://discourse.sst.dev/u/gregdalzotto)\
**Post date:** [October 18, 2021, 10:45pm UTC](https://discourse.sst.dev/t/how-to-automatically-resize-images-with-serverless/2399/4 "2021-10-18T22:45:49Z")

</div>

With public access, the bucket’s objects are visible with my assigned cloudfront URL, but I would like to keep the private acces in objects, and load the files with cloudfront URL.

---

<div class="post-metadata">

**Author:** ![frank](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/frank/32/1183_2.png) [@frank](https://discourse.sst.dev/u/frank)\
**Post date:** [October 19, 2021, 12:29am UTC](https://discourse.sst.dev/t/how-to-automatically-resize-images-with-serverless/2399/5 "2021-10-19T00:29:28Z")

</div>

Hey @gregdalzotto, I don’t think the bucket need public access in order to attach it to a CF distribution. We actually have a similar setup for our `StaticSite` construct - [StaticSite | Serverless Stack (SST)](https://docs.serverless-stack.com/constructs/StaticSite)

The bucket is created here - [serverless-stack/StaticSite.ts at master · serverless-stack/serverless-stack · GitHub](https://github.com/serverless-stack/serverless-stack/blob/master/packages/resources/src/StaticSite.ts#L261-L265)

And it is attached to a distribution here - [serverless-stack/StaticSite.ts at master · serverless-stack/serverless-stack · GitHub](https://github.com/serverless-stack/serverless-stack/blob/master/packages/resources/src/StaticSite.ts#L393-L399)

Let me know if that makes sense.
