Wednesday, April 1, 2020

HowTo install AWS SAM CLI in Amazon Linux (option w/o using docker)


To start with serverless deployments, i.e., to start testing and deploying AWS Lambda functions, we can do it many ways like AWS Cloudformation, AWS SAM CLI etc

This post is to explain and detail about the steps to install AWS SAM CLI in your EC2 instance, which is Amazon Linux

What is AWS SAM CLI:


Getting Started:
  • AWS account & user login access 
  • Access to EC2 instances of Amazon linux with Lambda access, as well

Steps to get AWS SAM CLI installed: 
  • Login to the EC2 instance where AWS SAM CLI is planned to be installed
  • Apply command "sudo pip install aws-sam-cli". This doesnt work as we need PIP


  • to install PIP, first we need to install epel-release; In Amazon linux, epel-release is bundled in amazon-linux-extras 

  • Now install with "sudo amazon-linux-extras install epel" as above
  • Install PIP

  • Install aws-sam-cli but raises below error 

  • Install gcc

  
  • Now re-try installing "sudo pip install aws-sam-cli

  • As the above message says that Python 2.7 is no longer supported for running SAM Applications, let us upgrade the Python version and see how this works 
  • sudo pip install python3

 
  • Now upgrade SAM, if required
                                       sudo pip install aws-sam-cli --upgrade

  • Initiate SAM

This is an prolonged mode of installing AWS SAM CLI, ideally it is better to proceed in this sequence
  1. Update the instance using "sudo yum update"
  2. Apply Python3 using "sudo yum install python3
  3. Now install aws-sam-cli using above steps
 In the next post let us see, how to install SAM in conventional way

No comments:

Post a Comment