9 Steps To Deploy Serverless HTTP API To AWS Using SAM & Pycharm | Deploy Lambda, API From Local Box
In this tutorial, you'll learn how to deploy a serverless HTTP API application to AWS using SAM & Pycharm from a local machine. — Facebook: https://www.facebook.com/GokceDBsql — Video Transcript: — Hi guys, this is Abhi from Gokcedb. In this video, you are going to learn how to insert data into the Dynamodb using a Lambda function. Let’s start by searching for Dynamodb on the AWS Console then hit Create Table. Enter the name of the table partition key and sort key and for Table Setting, I’m going to leave everything to default and then click on create a table. Once the table is created, click on explore items in the left menu. Click on the Create Item button and give a value for the property underscore state and property id. Looks like our insert went through as expected. Now let’s go back to AWS Console and search for IAM which stands for Identity and Access Management. Click on roles in the left menu then hit the Create Role button. Choose Lambda and hit next. Search for Dynamodb and Select Dyamodb full access then click next. Give this role a name and then the Create Role button. This will ensure that our Lambda function will have full access to the Dynamodb. Go back to AWS Console and this time search for Lambda. Click on create function and give your function a name. For runtime, I’m going to select Python and for Default Execution Role, we're going to select the full Dynamodb Role that we just created. In the Code Source Section, I’m going to copy-paste pre-written Python Code. On line 2, I’m importing the borto 3 library which is the SDK for AWS. On line 4, I’m creating the Dynamodb Client. And on line 5, I’m calling the property table. Inside the Lambda underscore handler function, I’m using the put underscore item method to insert the event in the property table. On line 10, I’m returning the table. The scan will return all the items from the property table. Next, click on the test button and give your Test Event a name. For event Json key-value pairs, I’m going to specify the values for property ID, State, and County. Hit save then click on deploy. Click on deploy. Click on test again and you should see a response pack with a table dot scan value. You can also go back to the Dynamo DB interface and hit the refresh button to see whether our insert went through or not. Next, let’s configure the test event so we can change our insert values. This time, I’m going to specify California as my State and San Diego as my County. Click on the test button to test your Lambda function one more time and go back to the Dynamodb interface to confirm our second insert went through. There you have it. Make you like, subscribe and turn on the notification bell. Until next time. Install AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html Install SAM: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-mac.html Install Docker: https://docs.docker.com/desktop/install/mac-install/ Install PyCharm Professional: https://www.jetbrains.com/pycharm/download/#section=mac Install AWS Toolkit Plugin in Pycharm Create IAM User Use "aws configure" to add the security credentials Create AWS Serverless Application Project in PyCharm Deploy your SAM App to AWS from PyCharm -- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Parameters: StageName: Type: String Default: Prod Resources: HttpApiFunction: Type: AWS::Serverless::Function Properties: CodeUri: hello_world/ Handler: app.lambda_handler Runtime: python3.9 Architectures: - x86_64 Events: ExplicitApi: # warning: creates a public endpoint Type: HttpApi Properties: ApiId: !Ref HttpApi Method: GET Path: /path TimeoutInMillis: 15000 PayloadFormatVersion: "2.0" RouteSettings: ThrottlingBurstLimit: 600 HttpApi: Type: AWS::Serverless::HttpApi Properties: StageName: !Ref StageName Tags: Tag: Value AccessLogSettings: DestinationArn: !GetAtt AccessLogs.Arn Format: $context.requestId DefaultRouteSettings: ThrottlingBurstLimit: 200 RouteSettings: "GET /path": ThrottlingBurstLimit: 500 # overridden in HttpApi Event StageVariables: StageVar: Value FailOnWarnings: true AccessLogs: Type: AWS::Logs::LogGroup Outputs: HttpApiUrl: Description: URL of your API endpoint Value: Fn::Sub: 'https://${HttpApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/${StageName}/' HttpApiId: Description: Api id of HttpApi Value: Ref: HttpApi
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.