Instructor: 0:00 We have a SAM application defined in this YAML file over here, which is going to deploy this Lambda function. We would like to build and deploy the function to AWS. Let's go to our terminal.
0:09 In order to build a SAM application, run sam build. That is going to take a second. We can see that the build has exceeded and also the artifacts were created.
0:18 Now we can do two things. We can either invoke the function locally, or we can deploy it to AWS. We're going to copy this command and paste it in order to deploy it. Since this is the first time that we are deploying this application, SAM is going to ask us a bunch of questions. First up, what's the stack name? I'm going to call it Egghead App Stack.
0:39 Next question is, which AWS region I would like to use in order to deploy this app? The default one is us-east-1, but I'm based in Europe, so I'm going to go with eu-central-1, which is based in Frankfurt.
0:50 Now it's going to ask us whether we want to confirm changes to resources every single time we deploy. I think the safe option is yes, because we want to be sure that we are not deploying something that we don't need.
1:01 Next, we need to give SAM the permissions to create roles, in order to connect the resources in our template. For instance, our Lambda function in API Gateway, so I'm going to go with yes.
1:10 Last question is whether we want to save all those answers that we just gave into a SAM config file. We want to, because we don't want to answer those questions every single time we want to deploy this function.
1:21 Now, it's going to initialize the deployment to AWS. Before the actual deployment may happen, SAM will create a cloud formation template for us, which is going to contain all the necessary resources such as the Lambda function, and also the API Gateway REST API, along with all the necessary roles and permissions in order for this API to work.
1:39 I'm OK with those changes. I'm going to say, "Yes, please do deploy this change set." Now the actual deployment is going to start. This might take a second, so I'm going to pause the video and resume it after it's done. Our deployment is complete. We get to verify the outputs of our stack.
1:55 There's three of them. Two of them are the Amazon Resource Name for both the IM role, created for this Hello World function, as well as the Amazon Resource Name for the Lambda function itself. The one that is most important for us right now is the actual API endpoint. I'm going to copy that, and we're going to send a GET request to this endpoint.
2:14 We can see that our function has been successfully deployed, because I'm getting a message "Hello World," which was defined in our Lambda function over here.