{"id":557,"date":"2018-09-11T09:40:19","date_gmt":"2018-09-11T07:40:19","guid":{"rendered":"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/"},"modified":"2021-03-29T16:54:29","modified_gmt":"2021-03-29T14:54:29","slug":"go-serverless-lets-create-a-file-sharing-application-based-on-aws-services","status":"publish","type":"post","link":"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/","title":{"rendered":"Go Serverless! Part 1: let\u2019s create a File Sharing application based on AWS services"},"content":{"rendered":"
\n
\n
\n

Go to part 2<\/a> | Go to part 3<\/a><\/p>\n

In recent years, the term\u00a0\u201cServerless\u201d<\/strong>\u00a0has become more and more popular in the IT world.<\/p>\n

Another Buzzword? Or is it indeed possible to develop an application that does not use any servers, as this word would suggest? Let\u2019s try to clarify this possible misunderstanding\u2026<\/p>\n<\/div>\n<\/div>\n<\/section>\n

\n
Serverless<\/em>\u00a0is a\u00a0Cloud paradigm<\/strong> that allows applications to run independently from the underlying infrastructure. Thanks to Cloud services such as (for example)\u00a0AWS Lambda, API Gateway, and EKS<\/strong>, it is possible to develop applications for which provisioning, scalability, and management operations are carried out transparently and automatically, without manual intervention from those who write the code.<\/div>\n
\n
\n

This new technology has many advantages which improve the experiences of both user and developer. Knowing how to make the most of them is crucial to creating highly scalable, high-performance competitive solutions.<\/p>\n

With this 3-article series, we will explain how to build a\u00a0file-sharing system <\/strong>complete with login, \u201cdrag and drop\u201d capability and file sharing using links, exploiting the potential of serverless technology and the services provided by AWS.<\/p>\n<\/div>\n<\/div>\n<\/section>\n

\n
Amazon offers a wide range of managed services<\/strong> that can be used to implement completely serverless architecture rapidly: we will, therefore, create infrastructure as shown in the illustration below, then analyze in detail how to configure the necessary triggers for responding to events, such as file uploads.<\/div>\n
\n
\n
\n
\n
<\/div>\n
<\/canvas><\/div>\n<\/div>\n<\/figure>\n

The application will consist of a static front-end and a range of back-end APIs, both protected by authentication. File information and sharing data will be saved to a key-value type database, while all files will be saved to object storage.<\/p>\n

There is an interesting point worth noting: user uploads will be carried out directly to object storage through a specific authorization mechanism. This will allow the application to\u00a0scale rapidly<\/strong>\u00a0to face increasing requests, minimizing the resources to allocate in advance and their related costs.<\/p>\n

In order to create this solution, we will employ some of the most interesting Serverless services, such as\u00a0S3<\/strong>\u00a0for the storage of objects,\u00a0DynamoDB<\/strong>\u00a0as a database,\u00a0Lambda<\/strong>\u00a0for the execution of back-end APIs,\u00a0API Gateway<\/strong>\u00a0to display the APIs,\u00a0CloudFront<\/strong>\u00a0as a CDN to serve the front-end, and\u00a0Cognito <\/strong>for user sign-ins and authentication services.<\/p>\n

We will also tackle the topic of automatic code deployment, creating a pipeline of\u00a0Continuous Deployment\/Continuous Integration<\/strong>\u00a0that allows software modifications to be issued quickly and automatically.<\/p>\n

\n
\n
<\/div>\n
<\/canvas><\/div>\n<\/div>\n<\/figure>\n

To be specific, two separate pipelines will be created to handle the front and back-end CD\/CI. The back-end one will use a CloudFormation template to carry out Lambda function provisioning and update the code, while the front-end one will copy assets to the appropriate bucket and manage the CDN with the necessary invalidations.<\/p>\n<\/div>\n<\/div>\n<\/section>\n

\n
Let\u2019s start illustrating the services that are utilized according to design choices.<\/div>\n
\n
\n

Amazon S3<\/strong><\/p>\n

\u201cAmazon S3 is an object storage service created to memorize and restore any volume of data from any source. It is a service that provides extremely durable, readily available storage infrastructure with unlimited scalability, at a lower cost.\u201d<\/em><\/p><\/blockquote>\n

We will use S3 both as a source for files that make up the front-end application and as storage for user-uploaded files. Using this service allows for a virtually unlimited, highly-available space at a lower cost.<\/p>\n

To make the implementation more secure, we will use two separate buckets to subdivide better permissions and keep application storage strictly isolated from user data storage.
\nThe bucket reserved for static assets will be the source for the CDN utilized to distribute the front-end to clients.<\/p>\n

CloudFront<\/strong><\/p>\n

\u201cAmazon CloudFront is a global Content Delivery Network (CDN) that allows the distribution of data, videos, applications, and APIs to users with minimal latency and high transfer rates.\u201d<\/em><\/p><\/blockquote>\n

We will use CloudFront to serve the front-end of our application. In addition to improving performance and user experience, it also provides protection against\u00a0DDoS attacks<\/strong>\u00a0and reduces access costs to S3 for files that are frequently requested.<\/p>\n

DynamoDB<\/strong><\/p>\n

\u201cAmazon DynamoDB is a non-relational database that provides reliable performance on any scale. It is a multi-master, multi-region, fully-managed database that provides a constant latency of a few milliseconds, integrated security, a backup and restore service and a memory cache.\u201d<\/p><\/blockquote>\n

DynamoDB wins over other valid DBMS because the application saves metadata related to the uploaded files and their sharing settings, where everything is strong \u201cfile centric.\u201d The data structure fits well with the key-value model of DynamoDB, a condition which among other things is made possible by delegating the management of authorizations and user information to Cognito.<\/p>\n

Furthermore, by choosing to use DynamoDB, the application benefits from a database in an almost fully automatic way. The database is\u00a0fully managed<\/strong>, readily available, and easily and automatically horizontally-scalable.<\/p>\n

Cognito<\/strong><\/p>\n

\u201cAmazon Cognito allows tools to be quickly and easily added for logging, access and Web app and mobile device access controls. Amazon Cognito allows resources to be recalibrated for millions of users and supports access with social identity providers like Facebook, Google and Amazon and corporate identity providers via SAML 2.0.\u201d<\/em><\/p><\/blockquote>\n

We chose to delegate authentication and user data management to a managed service. This allows us to limit the attack perimeter of the service we\u2019re building, increase login and authentication possibilities, and provide a fast, bulletproof integration with API Gateway. The latter allows us to reduce costs because all the effort of authentication is carried out by the gateway and does not affect the Lambdas\u2019 calculation time. Furthermore, any incorrect login attempts or calls made with expired or incorrect tokens will never reach the application but will be handled directly on the architecture\u2019s outer perimeter.<\/p>\n

The managed user data service also allows us to eliminate database traffic to find key information about users. It\u00a0minimizes maintenance<\/strong>, the securing of tables with sensitive data, and credential management.<\/p>\n

Lambda<\/strong><\/p>\n

\u201cAWS Lambda allows code to be run without having to manage servers or carry out provisioning. Rates are calculated based on processing times, so no charges are made when the code is not running.\u201d<\/em><\/p><\/blockquote>\n

The back-end will be developed entirely with AWS Lambda. This technology\u200a\u2014\u200akey to the serverless philosophy\u200a\u2014\u200aallows us to pay for single operations and only for the time it is actually used, eliminating wastage of processing power and costs when the system is idle. It also saves us from having to configure and test an adequate auto-scaling policy.<\/p>\n

API Gateway<\/strong><\/p>\n

\u201cAmazon API Gateway is a fully managed service that simplifies for developers the creation, publication, maintenance, monitoring, and protection of APIs on any scale.\u201d<\/em><\/p><\/blockquote>\n

In this case, it\u2019s an obvious choice; only AWS API Gateway has all the hooks and integrations necessary for seamless and effective assimilation into the application architecture. The main goal is to provide a readily available, high performance, reliable interface for back-end lambda functions. It also allows integration with Cognito for authenticating calls and passing them on to the back-end only if they are correctly authenticated and legitimate, effectively blocking all invalid requests. Another advantage is that we can easily integrate CloudFront to cache the back-end responses in order to reduce computing times<\/strong>\u00a0and, at the same time, increase application responsiveness by reducing latency.<\/p>\n<\/div>\n<\/div>\n<\/section>\n

\n
<\/div>\n
\n
\n

In the next articles, we will take a detailed look at the application structure, serverless infrastructure, and the triggers to configure in order to respond to events significant to the application.<\/p>\n

Stay tuned!<\/p>\n

Go to part 2<\/a> | Go to part 3<\/a><\/p>\n<\/div>\n<\/div>\n<\/section>\n","protected":false},"excerpt":{"rendered":"

Go to part 2 | Go to part 3 In recent years, the term\u00a0\u201cServerless\u201d\u00a0has become more and more popular in […]<\/p>\n","protected":false},"author":6,"featured_media":656,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[478],"tags":[264,365,369,272,268],"yoast_head":"\nGo Serverless! Part 1: let\u2019s create a File Sharing application based on AWS services - Proud2beCloud Blog<\/title>\n<meta name=\"description\" content=\"Go Serverless! Part 1: let\u2019s create a File Sharing application based on Amazon Web Services\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building a Serverless File Sharing application on AWS\" \/>\n<meta property=\"og:description\" content=\"Go Serverless! Part 1: let\u2019s create a File Sharing application based on Amazon Web Services\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/\" \/>\n<meta property=\"og:site_name\" content=\"Proud2beCloud Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-11T07:40:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-29T14:54:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.besharp.it\/wp-content\/uploads\/2019\/06\/1_MexVO3w11jBTV-yn2VaHsw.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Alessandro Gaggia\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Building a Serverless File Sharing application on AWS\" \/>\n<meta name=\"twitter:description\" content=\"Go Serverless! Part 1: let\u2019s create a File Sharing application based on Amazon Web Services\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/blog.besharp.it\/wp-content\/uploads\/2019\/06\/1_MexVO3w11jBTV-yn2VaHsw.png\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alessandro Gaggia\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/\",\"url\":\"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/\",\"name\":\"Go Serverless! Part 1: let\u2019s create a File Sharing application based on AWS services - Proud2beCloud Blog\",\"isPartOf\":{\"@id\":\"https:\/\/blog.besharp.it\/#website\"},\"datePublished\":\"2018-09-11T07:40:19+00:00\",\"dateModified\":\"2021-03-29T14:54:29+00:00\",\"author\":{\"@id\":\"https:\/\/blog.besharp.it\/#\/schema\/person\/f27fc12d10867c6ea6e0158ce4dd8924\"},\"description\":\"Go Serverless! Part 1: let\u2019s create a File Sharing application based on Amazon Web Services\",\"breadcrumb\":{\"@id\":\"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.besharp.it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go Serverless! Part 1: let\u2019s create a File Sharing application based on AWS services\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.besharp.it\/#website\",\"url\":\"https:\/\/blog.besharp.it\/\",\"name\":\"Proud2beCloud Blog\",\"description\":\"il blog di beSharp\",\"alternateName\":\"Proud2beCloud Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.besharp.it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.besharp.it\/#\/schema\/person\/f27fc12d10867c6ea6e0158ce4dd8924\",\"name\":\"Alessandro Gaggia\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.besharp.it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f58dc28050f26409e22ab60346d06220?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f58dc28050f26409e22ab60346d06220?s=96&d=mm&r=g\",\"caption\":\"Alessandro Gaggia\"},\"description\":\"Head of software development di beSharp, Full-Stack developer, mi occupo di garantire lo stato dell\u2019arte di tutta la nostra codebase. Scrivo codice in quasi ogni linguaggio, ma prediligo Typescript. Respiro Informatica, Game design, Cinema, Fumetti e buona cucina. Disegno per passione!\",\"url\":\"https:\/\/blog.besharp.it\/author\/alessandro-gaggia\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go Serverless! Part 1: let\u2019s create a File Sharing application based on AWS services - Proud2beCloud Blog","description":"Go Serverless! Part 1: let\u2019s create a File Sharing application based on Amazon Web Services","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/","og_locale":"en_US","og_type":"article","og_title":"Building a Serverless File Sharing application on AWS","og_description":"Go Serverless! Part 1: let\u2019s create a File Sharing application based on Amazon Web Services","og_url":"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/","og_site_name":"Proud2beCloud Blog","article_published_time":"2018-09-11T07:40:19+00:00","article_modified_time":"2021-03-29T14:54:29+00:00","og_image":[{"width":800,"height":400,"url":"https:\/\/blog.besharp.it\/wp-content\/uploads\/2019\/06\/1_MexVO3w11jBTV-yn2VaHsw.png","type":"image\/png"}],"author":"Alessandro Gaggia","twitter_card":"summary_large_image","twitter_title":"Building a Serverless File Sharing application on AWS","twitter_description":"Go Serverless! Part 1: let\u2019s create a File Sharing application based on Amazon Web Services","twitter_image":"https:\/\/blog.besharp.it\/wp-content\/uploads\/2019\/06\/1_MexVO3w11jBTV-yn2VaHsw.png","twitter_misc":{"Written by":"Alessandro Gaggia","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/","url":"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/","name":"Go Serverless! Part 1: let\u2019s create a File Sharing application based on AWS services - Proud2beCloud Blog","isPartOf":{"@id":"https:\/\/blog.besharp.it\/#website"},"datePublished":"2018-09-11T07:40:19+00:00","dateModified":"2021-03-29T14:54:29+00:00","author":{"@id":"https:\/\/blog.besharp.it\/#\/schema\/person\/f27fc12d10867c6ea6e0158ce4dd8924"},"description":"Go Serverless! Part 1: let\u2019s create a File Sharing application based on Amazon Web Services","breadcrumb":{"@id":"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.besharp.it\/go-serverless-lets-create-a-file-sharing-application-based-on-aws-services\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.besharp.it\/"},{"@type":"ListItem","position":2,"name":"Go Serverless! Part 1: let\u2019s create a File Sharing application based on AWS services"}]},{"@type":"WebSite","@id":"https:\/\/blog.besharp.it\/#website","url":"https:\/\/blog.besharp.it\/","name":"Proud2beCloud Blog","description":"il blog di beSharp","alternateName":"Proud2beCloud Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.besharp.it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.besharp.it\/#\/schema\/person\/f27fc12d10867c6ea6e0158ce4dd8924","name":"Alessandro Gaggia","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.besharp.it\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f58dc28050f26409e22ab60346d06220?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f58dc28050f26409e22ab60346d06220?s=96&d=mm&r=g","caption":"Alessandro Gaggia"},"description":"Head of software development di beSharp, Full-Stack developer, mi occupo di garantire lo stato dell\u2019arte di tutta la nostra codebase. Scrivo codice in quasi ogni linguaggio, ma prediligo Typescript. Respiro Informatica, Game design, Cinema, Fumetti e buona cucina. Disegno per passione!","url":"https:\/\/blog.besharp.it\/author\/alessandro-gaggia\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.besharp.it\/wp-json\/wp\/v2\/posts\/557"}],"collection":[{"href":"https:\/\/blog.besharp.it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.besharp.it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.besharp.it\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.besharp.it\/wp-json\/wp\/v2\/comments?post=557"}],"version-history":[{"count":0,"href":"https:\/\/blog.besharp.it\/wp-json\/wp\/v2\/posts\/557\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.besharp.it\/wp-json\/wp\/v2\/media\/656"}],"wp:attachment":[{"href":"https:\/\/blog.besharp.it\/wp-json\/wp\/v2\/media?parent=557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.besharp.it\/wp-json\/wp\/v2\/categories?post=557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.besharp.it\/wp-json\/wp\/v2\/tags?post=557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}