DEV Community

Cover image for Create your own Image CDN using AWS CloudFormation and AWS Lamda

Create your own Image CDN using AWS CloudFormation and AWS Lamda

Ahmed Adel on February 25, 2022

➥ In this article, I will demonstrate how to create your own Image CDN in a few simple steps using AWS CloudFormation and AWS Lamda (Serverless). ...
Collapse
 
yongchanghe profile image
Yongchang He

Thank you for sharing such detailed information about the picture processing tool in AWS.

Collapse
 
ahmedadel profile image
Ahmed Adel

You are welcome :)

Collapse
 
vadorequest profile image
Vadorequest

For reference, here is the source code:
github.com/aws-solutions/serverles...

Collapse
 
alex_dim profile image
aljosa dimitrijevic

Hi, i created this stuck and i got message from AWS after some time.
Does this message means something important that i need to take action for ?
Message itself:

"AWS CDK v1 is now in maintenance mode"
"You are receiving this notification because you currently have at least one CloudFormation Stack deployed using version 1 of the AWS Cloud Development Kit (CDK). AWS CDK v1 is now in maintenance mode. During maintenance mode, AWS CDK v1 releases will contain new and updated resource level "L1" constructs, critical bug fixes, and security updates only. CDK v1 will not receive higher-level "L2" construct updates for new or existing services while in maintenance mode. Maintenance mode has a duration of 12 months.

After June 1, 2022, the AWS CDK team is focusing all efforts on adding new features and bug fixes to CDK v2 only. To continue to receive API updates, new features and bug fixes, migrate to AWS CDK v2 today. Check out the migration guide [1] to get started.

On June 1, 2023, CDK v1 will reach end-of-support. After this date, the AWS CDK v1 will no longer receive updates or releases. Previously published releases will continue to be available via public package managers and the code will remain on GitHub. Use of a CDK version which has reached end-of-support is done at your own discretion. We recommend you upgrade to the new major version.

For more information, see this AWS Blog Post from December 12, 2021 [2], and this GitHub issue from April 8, 2022 [3].

If you have any issues, or need support in migrating, please open a discussion on GitHub [4], or an issue in the aws-cdk GitHub repository [5].

If you require further assistance, reach out to AWS Support [6].

[1] docs.aws.amazon.com/cdk/v2/guide/m...
[2] aws.amazon.com/blogs/developer/how...
[3] github.com/aws/aws-cdk/issues/19836
[4] github.com/aws/aws-cdk/discussions...
[5] github.com/aws/aws-cdk/issues/new/...
[6] aws.amazon.com/support
"

Collapse
 
duyquocnguyen profile image
duyquocnguyen

Thank you and I have a question, I have upload a video with .mp4 and I can't into. Maybe this is error with api gateway. But I don't know modyfi them.

{"status":400,"code":"RequestTypeError","message":"The type of request you are making could not be processed. Please ensure that your original image is of a supported file type (jpg, png, tiff, webp, svg) and that your image request is provided in the correct syntax. Refer to the documentation for additional guidance on forming image requests."}

Collapse
 
abeskazali profile image
Ali Beşkazalı • Edited

If you want change video resize, file type or etc. on AWS, you should use AWS Elemental MediaConvert service. You can check this link for CloudFormation template.
aws.amazon.com/tr/solutions/implem...

Collapse
 
ahmedadel profile image
Ahmed Adel • Edited

This CDN is for resizing images only, it does not support video files.

Collapse
 
gnprojects profile image
gn-projects

I have some issue, didn't yet tried with aws object storage, but i keep getting 429 error which is too many requests are done per seconds.

Will this "own" sort of can handle such? Or does it read from the object storage on each get request?

Did you face such error?

Collapse
 
nikola8 profile image
Nikola

Hi Ahmed,

First of all, thanks a lot for your great article! 🙏🏼 The way you write is just great. 🥇 As you said, it’s pure magic using only one image for all sizes. I’m already testing ImageKit, but as I’m handling massive amounts of images the bandwidth limit just does not fit.

May I ask you to help me clarify following scenario:

I’ve created a WordPress based real estate portal. The amount of images grows exponentially, specially because of the auto-created resizings. Do you know how to make WordPress use the CDN created resizing? In other words, the theme auto-creates about 9 resized versions of the source image and all images are uploaded to the AWS S3 bucket. Afterwards, images are served optimized via CDN. But, how will the WordPress theme know that instead of using previously created resized versions, it is actually going to use the resized versions served by the CDN?

Best regards,
Nikola.

Collapse
 
antimoron profile image
AntiMoron

Following this guide, aws just created 122 resouces which really made me feel nervous about the fee.

Collapse
 
ahmedadel profile image
Ahmed Adel

Image description

This is the whole architecture of the solution, and a pricing model is attached in the article above, I'm using this myself btw, you can try it for a short amount of time or estimate the cost using CloudFormation.
Also you can easily drop all the resources whenever you want using CloudFormation