# Hello World ## Step 1 - Install Pre requisites #### We need to make sure we have the follwoing installed on our pc: * AWS CLI - We need to install the AWS Command Line Interface [Here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html). * Docker - We need to install Docker from the official website [Here](https://docs.docker.com/engine/install/). * AWS SAM CLI - Install the AWS SAM CLI. ## Step 2 - Setup AWS User and Credentials #### We'll need to create a AWS account [Here](https://signin.aws.amazon.com/signin?redirect_uri=https%3A%2F%2Fus-east-1.console.aws.amazon.com%2Fiamv2%2Fhome%3Frefid%3D6c16af2d-a3a1-477e-8969-4ba28eb8be90%26region%3Dus-east-1%26state%3DhashArgs%2523%26isauthcode%3Dtrue&client_id=arn%3Aaws%3Aiam%3A%3A015428540659%3Auser%2Fiamv2&forceMobileApp=0&code_challenge=_gHIBGdmvoUis0ggF74lCeZ8tEkMSXZOq2Gp2-V7fVo&code_challenge_method=SHA-256). We'll create a new user on Identity and Access Management (IAM), enter a user name, select "Access Key - Programming access" in AWS access type. Subquently we''l need to pick AdministratorAccess so that we won't have any access problems. One we have all these steps accomplished we'll be able to see our access key and Secret access key (save it). We'll use these to configure our AWS in CMD. #### On our terminal we should execute the following command: -------------------------- aws configure -------------------------- #### We'll need to enter our Access Key ID, Secret Access Key, default region (EU-west1) and default output format. ## Step 3 - Create a new SAM project #### We'll need to create a new directory for our SAM project and navigate into it: -------------------------- mkdir sam_project cd sam_project -------------------------- #### Initialize the new SAM project: -------------------------- sam init --runtime python3.9 -------------------------- ## Step 4 - Develop our Lambda Function #### Navigate to the directory of our Lambda function. -------------------------- cd sam_project/helloWorld -------------------------- #### Edit the app.py file to modify the Lambda Function's logic. ## Step 5 - Local Testing #### To check if our Lambda function can be reached we should use the following code -------------------------- aws lambda get-function --function-name FunctionName -------------------------- #### We can locally test our Lambda function by using the SAM CLI: -------------------------- sam local invoke -------------------------- or -------------------------- aws lambda invoke --function-name FunctionName --payload InputPayload outfile.txt -------------------------- Replace FunctionName with the actual name of our Lambda function and adjust InputPayload to the appropriate input data in JSON format. ## Step 6 - Build and Deploy #### Build our SAM application -------------------------- sam build -------------------------- #### Deploy our SAM application -------------------------- sam sam deploy --guided -------------------------- #### Follow the prompts to configure the deployment. SAM will create a CloudFormation stack with the Lambda function and necessary resources. ## Step 7 (Optional) - Clean Up #### If we want to delete the resources created by SAM: -------------------------- aws cloudformation delete-stack --stack-name <stack-name> --------------------------