Serverless services, like AWS Lambda, have been proven useful to solve a wide range of problems, and its use is growing rapidly. Recently, the possibility to use the PHP runtime in Lambda was added, so why not trying to use our favourite framework? How can we make the most from a serverless approach? What are pros and cons? In this session we will analyze the necessary steps to set up a Symfony4 project in Lambda and deploy it.
sfday Italy will be back soon, keep in touch!
www.sfday.it Twitter @sfdayit Newsletter: http://bit.ly/grusp-nl
Oh. Oh. Thank you. Thanks to be here, this talk is about Symfony and EWR lamda. Before we start, I would like to know how many of you have already used Alamdar service the. OK, and how many of you have already used the alumni service with Symphonie? One guy. OK, nice, so my name is inaccurate and I am a software developer, working, flowing. I work usually in Northern B and not Jesus and I love to contribute on open source library, on GitHub and on the stack overflow community. You can find me on Twitter with this nickname, you know, or on GitHub with this nickname. When we talk about LAMDA, we are talking about Serverless. And the first time that I've heard this word, I suddenly thought, oh, my God, no salver, no backhand, no, I will lose my job. And this thought scared me a lot for some weeks until the day I have decided to understand, well, what does really mean Serverless and they have discovered that Southernness doesn't mean that I will lose my job. Instead, we have a new amazing tool for our job, a new amazing tool to learn and will off to the right, because Cervalis means that you don't have to worry about software, architecture, infrastructure, create service, because in this case, AWEX ableist takes to care for the infrastructure for you. You don't have to create so mundane update, you can focus only on your code, and a lambda is a civil service provided by a W.S., its function as a service, and it provides to run code without provisioning or major service events that can trigger our code. And you pay only for the compute time you consume. The last point means that. Usually you pay the green area and the blue area together, you pay always the same money every month. If you have a standard server and he set you up. Yes. The blue area is the usage of the server. OK, we slammed with LAMDA, you pay only the usage of the server. You can save a lot of money and the cost is really cheap, zero point zero zero zero zero zero zero dollars per request and the first meeting of requests per month are free. If you need the more CPU memory or more configuration, more complex, you need to pay more, but not so much. When it was released, the LAMDA, it supported only a few languages and HP wasn't one of them, clearly. But in the last year, A.W. has announced that LAMDA support HP implementation, implementation. I was really happy and I have suddenly tried something without success because they have found this into the documentation. Lamda support languages, not just Python or Ruby. Go C Sharp Powerset. What is BHP? How can I drop my application? You have told me that LAMDA support is now. Well, the previous now really means that you can write into the letter whatever you want. You can import FIES to manage your external dependencies. In our case, you need to import BHP Biner despise. But those miners, BHP, Binish, Phi's, aren't so easy to create. You need to follow the rules. It's not easy to create a on one maintain because if you need a new extension, you have to update. And it's not very easy. But we are lucky because a French developer has created an open source library called Breath that helps developers deploy application all lamda importing buyers file into delayer, which is generated by Brath community. It provides each times for a Lamda Ollaberry to interface code with Lamda API, a very rich documentation, deployment tools and a very nice community. Usually this is a standard scheme of your for an application that communicate with LAMDA via FBN layer that manage your EcoStar response with AP API three. And if we will deploy your application, you can send to your A.W. console on your browser, your application and under that layer with your important files in so how to deploy your smartphone application. Requirements you need any account with our society and a secret is key, obviously you have to create a lambda. It's not it's very easy to install and confuse civils framework. Pay attention, some of this framework, it's a library. Don't confuse it with Serverless work. You can be confused because they have the same name surveillance framework. It's the library. Now you need to install in the library. So first step is to configure the terminal with a config that will ask you to insert your credentials, default output format and the or your name. Now you can install surveillance framework with AMPA and configure it with your credentials again. Now you can install Brushoff Library with composer composer Requite Ruff Ruff and utilize it with VanDerBeek, but in it. This government generates two files on your project index, not BHB, where you can put your custom functions and some of the stuff, Yamal, a configuration file. This is a standard configuration file where usually you have to change only the original name and that the environment of your Sufan application. In this case, I have brought in this file. You can specify the layers you need to specify layers to use in this case, seven three FBN. Now we are ready to deploy. You need to optimize your dependencies with composer install optimized, I'm not have common. And you can deploy with Surveils deploy that generates some subroutines like that and in the end. You can see a link. And if you will click it, you can see your application, deploy it. We have done three, four comments, five, 10 minutes, you have deployed your cell phone application from scratch to LAMDA, very, very easy. But what really happened? Before I understand it, we need to understand why we are using some of this framework. Before it rough library use the alias Sam and opensource framework that helps developers to build the serverless application, it provides template specification and gumline interface. It's a tool for cloud formation. And cloud formation is a bunch of service that works together with a configuration. A bunch of service is like a three bucket and database's OK. And it is a configuration, but it's not very easy. It's a little bit complicated in my experience, and you can compare it with serverless framework configuration and you can see ADA blasphemies more along this. These are standard file. OK, Sam is more long, more nested and in my experience is more complicated and complex. Another advantage of some of the software markets, you can take a W.S. syntax and put into your serverless framework five. OK, you can do the opposite. Another advantage of serverless free markets is multi provider. It means that you can deploy on a W.S. or Nazeer. For example, a son can deploy only on a W.S.. For those reasons, rough community decided to switch from A.W. Sam to surveillance framework. And when you land some of the common interest translate configuration file, it creates an dabblers cloud formation template. It creates a stack. It is not red created with no source except for a necessary bucket where your zip code will be deployed. Now, surveillance framework compares ashes of new and old files, and if they are different, it generate a new version and deploy your code, your S3 bucket. Lambda automatically understands that new code uploaded and text. But pay attention, LAMDA is the only mode. It except for a folder, Tempe. So if you have your cash into your server, you need to change the path in this case, I have put the condition to understand if we are on LAMDA or not Lamda Tuscarora and if you are Orlanda, change the cash path to Tempy. Another case is cloud watch, for example, because lock files can be stored on cloud watch with this simple configuration you can send automatically log files to. Cloud watch and service that is linked to LAMDA. We have talking about environment variables, because everything from application use, environment variables, how can we use it? We have some services like I saw some parameters for a free service provided by a Dallas where every parameter is put inside that unique store. In my experience, a best practice is what the graphics we are permitted to understand, which application I use that parameter. And you can create those parameters from your console on your browser, or we've got with this government able to set aside some parameter, you need to specify region name, type and value, and you can declare it into your serverless framework file into this way with this syntax, please don't store environment variables values into this file for for security reasons. Another service is AWOL Secrets Manager and other WASC service, but this is not free because it has better management and you can store on values. So parameter with other parameters inside. Let's make an example, upload files with Symphony to AWB. You come right, and that's three service configuration like that with your environment variables. Your client, but potentially because there are some environment variables that are private from lamda like a region and keep it a secret. Now you can declare it into your soul YAML file this way, I have used the same syntax in this case. Now you can create your upload service that upload your files to a necessary bucket, a different battery bucket, different from that as three buckets that contains your zip code files, because sometimes you can destroy your lamda. And if you will destroy your lamda, you will lose your all your uploaded files. LAMDA could be destroyed to change if you need to change the region. OK. The next step could be to trigger our code from events. So we can have a lamda that upload our photos to Anatsui Bucket and another another LAMDA when the new photos is uploaded, takes it, take it and recite it. How can we do it with this simple configuration into your l'esprit modified in this case? I have specified that one. And even on this three Barkett photos and event of object created with those rules, graphics uploads and suffix that jpeg when an event like that happens. Lambasts, call it, and it calls and let that be where you can put your BHB code or you can run your cell phone application, whatever you want. You can have many, even many events like. OK. Another example is out the U.S., you can change the path of your assets into this way. You will need to change the base morale and put one point to another three bucket, and now there are three bucket different from that three bucket that contains your zip code for the same reason. If you are using what but you can use the syntax to change the public path. Some question about that. OK. How many of you use Docker to deploy to developing locally? It's not so easy to create a lambdas stack with Docker, but we are lucky because Brath Community creates a Docker file for you with Chugh Services and Weber with BRAF FBAR get the service image and breath BHB 7:00 p.m. for HP. And here you can declare your environment variables. In this case, you have the same stack of your lamda, you have to recreate your lamda. Now we can analyze some use, case and performance if you visit the site, you can see the maturity matrix like that with simplicity and performance is a reliability. Dubuisson crown are orange on simplicity. Bergreen on performance is ability. API are all green API with my sequin orange availability website or green legates application red on simplicity and reliability. But. Since last month, these mathematics was more read it as many rack points, because if you are using my Secret Service, my secret with some service on Posterous, you need to use ANADA as a relation at the base of a W.S. It means that you need to put your lamda into a virtual private cloud and virtual private cloud as called start. It means that when you call your lambda, it takes five seconds to get started. Very, very slow for this reason, it wasn't recommended to use Lamda with my secret or Posterous. But we got to look again at last month announced that they have improved, we'll be seeing that working, removing to start. So now you can use your bicycle basket without problems. This is a very big announcement for us. Let's analyze some jobs and grant, for example, because they are orange on simplicity, because jobs and grant are perfect for LAMDA, because they are a function or service or function. Call it sometimes. But they have a lack of integration with existing libraries for this reason, simplicity is orange. Red Points was for Lagus application because usually Lagus application or monolithic application, very big application, not designed for this type of architecture. In my experience, it's better to submit your application in Liggett's application into managed services and put some of that into Lambda. Why use a lambda because it reduces costs. It's very safe, no infrastructure to manage, and in 10 minutes or less, you have your application deployed from scratch. When is recommended to use a double lambda, when you don't have a complex configuration because it's not so easy to create and to maintain a to make good performance. It's recommended when you have an independent service, when you have a website, when Robert Jobson Chron, when we have an API based system and more and more and more. Thank you.