{"id":10193,"date":"2021-06-28T11:00:19","date_gmt":"2021-06-28T02:00:19","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=10193"},"modified":"2021-06-25T19:18:11","modified_gmt":"2021-06-25T10:18:11","slug":"a-touch-to-serverless-framework-part-2","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/10193","title":{"rendered":"A touch to serverless framework part 2"},"content":{"rendered":"\n<p>I talked about setting up IAM user and creating credentials on our computer. Today I will talk about creating our serverless project and start deploying to AWS cloud.<\/p>\n\n\n\n<p>If you haven&#8217;t read part 1 , feel free to check it out <a href=\"\/appnews\/archives\/10122\">here<\/a>. So lets get started.<\/p>\n\n\n\n<p>First lets build a folder, I will call it <strong>sls-api<\/strong> but you can name it whatever you want. Then lets go to our project , sls-api in my case and type this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sls create --template aws-nodejs<\/code><\/pre>\n\n\n\n<p>This means we will create a node js project template for our serverless application. I told you we are going to use node js for this series in article1. After running this command , we will get an output.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"1024\" height=\"325\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/8.sls-project-1024x325.png\" alt=\"\" class=\"wp-image-10194\" srcset=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/8.sls-project-1024x325.png 1024w, https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/8.sls-project.png 1436w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We will have to update the code configuration before deploying. Open <code>serverless.yml<\/code> which is the core configuration file of our serverless project. We will add a stage and region to connect with our AWS like this<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"1024\" height=\"109\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/image-12-1024x109.png\" alt=\"\" class=\"wp-image-10197\" srcset=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/image-12-1024x109.png 1024w, https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/image-12.png 1294w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><br><\/figcaption><\/figure>\n\n\n\n<p>But be aware of the region of AWS. If the regions don&#8217;t match, the deployment will not work. Then Type <code>sls deploy<\/code> and wait for the result. This will start deploying our application to AWS cloud and create the necessary things.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"1024\" height=\"475\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/9.sls-deploy-1024x475.png\" alt=\"\" class=\"wp-image-10195\" srcset=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/9.sls-deploy-1024x475.png 1024w, https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/9.sls-deploy.png 2034w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>As a result , our deployment will create a stack and lambda at AWS. As you see here, you have to know about AWS services a bit to understand these tutorial series because you are seeing stack and lambda etc. So If you don&#8217;t understand AWS, I recommend to read some articles about these services as we are focusing only on the serverless at the moment.<\/p>\n\n\n\n<p>Firstly it will create a stack. A&nbsp;<strong>stack<\/strong>&nbsp;is a collection of&nbsp;<strong>AWS<\/strong>&nbsp;resources that you can manage as a single unit. In other words, you can create, update, or delete a collection of resources by creating, updating, or deleting&nbsp;<strong>stacks.<\/strong>Lets go and checkout on <a href=\"https:\/\/console.aws.amazon.com\/cloudformation\/home\">AWS stack console<\/a> what the deployment build. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"1024\" height=\"437\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/10.aws-stack-1-1024x437.png\" alt=\"\" class=\"wp-image-10202\"\/><\/figure>\n\n\n\n<p>The name called sls-api is our project name and dev is the environment which we used to deploy our project. Furthermore, it will also create a lambda function. Lambda is a compute service that lets you run code without provisioning or managing servers. Lets go to <a href=\"https:\/\/console.aws.amazon.com\/lambda\/home\">Lambda console <\/a> and you will get a function like this.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"1024\" height=\"431\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/06\/11.1-aws-lambd-1-1024x431.png\" alt=\"\" class=\"wp-image-10203\"\/><\/figure>\n\n\n\n<p>That is all for this week. I will talk about invoking our functions and creating endpoints in our project next week.<\/p>\n\n\n\n<p>Yuuma<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10193\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/10193\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"A touch to serverless framework part 2\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10193\" data-text=\"A touch to serverless framework part 2\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10193\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10193\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>I talked about setting up IAM user and creating credentials on our computer. Today I will talk about creating  [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[35],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10193"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=10193"}],"version-history":[{"count":5,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10193\/revisions"}],"predecessor-version":[{"id":10206,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10193\/revisions\/10206"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=10193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=10193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=10193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}