Skip to content

gsy0911/zenn-cloudfront-resize-image

Repository files navigation

zenn-cloudfront-resize-image

cdk-version NodeVersion

  1. Access the server at https://your.domain.com/images/some_file.jpg?w=1280&h=960.
  2. Use Lambda@Edge to transform the URL to https://your.domain.com/images/w=1280&h=960&quality=50&ext=webp&fit=inside/some_file.jpg.
  3. Access S3 using the transformed URL.
  4. If the file exists in S3, proceed to step 6; if it doesn't exist, perform step 5.
  5. Convert the image at the original access location, images/some_file.jpg, and save it as images/w=1280&h=960&quality=50&ext=webp&fit=inside/some_file.jpg.
  6. Return either the retrieved file or the converted file.

zenn article

deploy step

  1. create infra/params.ts from example
$ cd infra
$ cp paramsExample.ts params.ts
  1. prepare your domain in Route53

  2. get Certificate of your domain in ACM

  3. edit params.ts and set parameters

  4. deploy via CDK

# in infrastructure directory
$ cdk ls
zenn-cf-resize-node-lambda
zenn-cf-resize-cloudfront

$ cdk deploy zenn-cf-resize-cloudfront
  1. access your file

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages