Policy:
A policy defines the AWS permissions that you can assign to a user, gourp, or role.
You can create and edit a policy in the visual editor and using JSON (AWS policy Generator)
Ex : Admin -> EC2 Permission (start,stop or Create, terminate.. or allow/deny whatever permission )
Particular Role policy is called inline policy
Roles :
A Role based on attached policy
- Trusted between AWS Services - Assumed between AWS Account Users - Web identity, SAML
IAM Role has no associated credentials
Max 1000 Roles Create – Soft Limit
IAM roles are a secure way to grant permissions to entities that you trust. Examples of entities include the following:
IAM user in another account
Application code running on an EC2 instance that needs to perform actions on AWS resources
An AWS service that needs to act on resources in your account to provide its features
IAM roles issue keys that are valid for short durations, making them a more secure way to grant access.
Processes involved
The following are the processes involved in working with AWS lambda and API Gateway −
1. Create IAM role for permission 2. Create AWS lambda function 3. Create API Gateway 4. Link lambda function to api gateway 5. Passing data to api gateway
Create User :
Go to IAM Add User Create UserName Set Permission (Copy existing or Attach existing policies) we get Access Key & Secret access key
AWS CLI Configuration in Windows
1 : Install Python
2 : Install AWS CLI from download and install page for windows vesion
3 : Check AWS CLI vesion “aws –version”
4 : Copy the Role arn
5 : Crate a index.js file and zip the file as well note the file path
6 : Create a command with follwing properties within a single line without enter key
aws lambda create-function
--function-name "***"
--runtime "nodejs12.x"
--role "arn:aws:iam::***/***"
--handler "***.handler"
--timeout ***
--memory-size ***
--zip-file "fileb://***"
7 : Example –
aws lambda create-function
--function-name "awsCliLambdaFunction"
--runtime "nodejs12.x"
--role "arn:aws:iam::00000:role/aws-cli-lambda"
--handler "index.handler"
--timeout 5
--memory-size 256
--zip-file "fileb://E:/Prabha/Local/AWS/index.zip"
8 : Go to command prompt and run command : aws configure
9 : Give the values as shown below –
AWS Access Key ID [****************I4BY]: ******
AWS Secret Access Key [****************R+0n]: *****
Default region name [None]: ap-south-1
Default output format [None]: json
10 : Run the below command –
C:\Users\Admin>aws lambda create-function --function-name "awsCliLambdaFunction" --runtime "nodejs12.x" --role "arn:aws:iam::000000:role/aws-cli-lambda" --handler "index.handler" --timeout 5 --memory-size 256 --zip-file "fileb://E:/Prabha/Local/AWS/index.zip"
{
"LastUpdateStatus": "Successful",
"FunctionName": "awsCliLambdaFunction",
"LastModified": "2020-12-23T10:36:15.098+0000",
"RevisionId": "****",
"MemorySize": 256,
"State": "Active",
"Version": "$LATEST",
"Role": "arn:aws:iam::****:role/aws-cli-lambda",
"Timeout": 5,
"Handler": "index.handler",
"Runtime": "nodejs12.x",
"TracingConfig": {
"Mode": "PassThrough"
},
"CodeSha256": "****",
"Description": "",
"CodeSize": 231,
"FunctionArn": "arn:aws:lambda:ap-south-1:00000:function:awsCliLambdaFunction",
"PackageType": "Zip"
}
C:\Users\Admin>python -v
ERROR : Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
Solution : Uninstall old Python versions and install new , please note the Python installation path, sometimes it choose Admin/Data/Local/ path
After successfully executed the function in lambda, we can not see the log in cloudWatch, it throws error warning as :
ERROR 2 :
“Log group does not exist
The specific log group: /aws/lambda/awsCliLambdaFunction does not exist in this account or region.”
It says that log group does not exist : The specified log group does not exist.
Solution : ?
Get the Access Key & Secret access key from console top menu select -> My security credentials -> Generate by click the create key button
1. Add user
1. aws configure :
2. Access Key & Secret access key
3. Region name :
Lambda sample applications 1
Lambda sample applications 2
Lambda sample applications 3
Using AWS Lambda with the AWS Command Line Interface 1
Using AWS Lambda with the AWS Command Line Interface 2
Deploy NodeJS Express API as AWS Lambda Function in 20 minutes
AWS Lambda Pricing: How Much it Costs to Run a Serverless Application?
10 AWS Lambda Use Cases to Start Your Serverless Journey
10 Practical Examples of AWS Lambda
How to make a Serverless Real Time Chat App
How to Build a Scalable Application up to 1 Million Users on AWS
AWS Lambda vs EC2: Comparison of AWS Compute Resources
Serverless vs Containers : Which one to choose in 2021?
Serverless Database – Everything you Need to Know
Exploring the Ecosystem of Serverless Technologies
AWS Lambda Performance Tuning & Best Practices (2020)
Serverless Architecture: A Comprehensive Guide
Node.js vs Python: Which one is a better backend technology?
Running a scalable & reliable GraphQL endpoint with Serverless
How to Make a Serverless GraphQL API using Lambda and DynamoDB
What are Serverless Components, and how do I use them?