AWS+Lambda+Full+Course Final 24+oct 2023
AWS+Lambda+Full+Course Final 24+oct 2023
1
Course Pre-Requisites
1. AWS Free Tier Account
Amazon SNS
AWS Managed
Microsoft AD
AWS Directory Service Lambda Authorizer
Amazon EBS
AWS Lambda, Python and Serverless – Key AWS Services
AWS Management and Governance AWS Database
Logs Alarm
Python Basics_Refresher_Part 1 (Python Print Function, Variables, Data Types Intro, Data Type – Dictionary )
Python Basics_Refresher_Part 2 (Nested Dictionary , List and Nested List , Data Type and Python Functions)
Section 4 : AWS Lambda – Create S3, EC2 and DynamoDB using AWS SDK for Python(Boto3)
• AWS Lambda Basics – Boto3, Client and Resource, Lambda function handler
• AWS Lambda with S3 (List all the buckets, Create new Bucket and Delete Bucket)
S3 EC2 DynamoDB P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
Section 5 : AWS Lambda – Basic Concepts – Part 2
• AWS Lambda Invocation Models – Theory
• S3
• AWS Lambda
• DynamoDB
• API Gateway - Deployment, API Stages, API Keys and Usage Plans
• API Gateway
• AWS Lambda
• S3
Lambda Authorizer
Authentication – External
Authorization – Lambda
Function
• Lambda Versions
• Lambda Aliases
• S3
• IAM Role
• AWS Lambda
• API Gateway
• Microsoft AD
• EC2
• FSx
• CloudWatch Metrics
• CloudWatch Alarm
I would love to Connect with you and together learn AWS. Connect with me at below links:
• Instagram - https://www.instagram.com/aws_with_rahul/
• Linkedin - https://www.linkedin.com/in/rahul-trisal-7709628/
• Youtube - https://www.youtube.com/@trisalrahul/videos
• AWS Startup - www.techcloudbyte.com
• Follow our LinkedIn page for latest on AWS - https://www.linkedin.com/company/tech-cloud-byte-techclobyte
AWS Lambda and Python – Beginner to Advanced
Section on
AWS Lambda – Basic Concepts (Part 1)
Source : Internet
Source : Internet
Source : Internet
Virtualization
Source : Internet
IaaS vs PaaS vs SaaS and FaaS
Function as a Service
Function (Code)
Source : Internet
AWS Lambda and Python – Beginner to Advanced
AWS Definition of Lambda
Lambda is a compute service that lets you run code without provisioning or managing servers. Lambda runs your code on a high-
availability compute infrastructure and performs all of the administration of the compute resources, including server and operating system
maintenance, capacity provisioning and automatic scaling, and logging.
• Compute Service
• Highly Available
• All of the administration of the compute resources, including server and operating system maintenance, automatic scaling, and logging.
• Event Driven
• Unpredictable demand
P.S : The content is created by Rahul Trisal and copyrighted Source : AWS
AWS Lambda and Python – Beginner to Advanced
Image Processing – S3 and AWS Lambda
P.S : The content is created by Rahul Trisal and copyrighted Source : AWS
Virtualization
Source : Internet
AWS Lambda and Python – Beginner to Advanced
AWS Lambda Execution Role
• A Lambda function's execution role is an AWS Identity and Access Management (IAM) role that grants the function
permission to access AWS services and resources.
• Need to provide an execution role when a function is created. Invoke your function, Lambda automatically provides your
function with temporary credentials by assuming this role.
Source : AWS
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
Section on
AWS Lambda - Python Refresher
(For detailed refresher go to last section of Course)
2. Variables - Containers for storing data values string, float or integers and no need to declare; Syntax : x = 3, greeting = “hello” etc.
3. Data Type
Int x = 20
Float x = 20.5
Dict
• curly brackets
response = {1: 'Rahul', 2: 'John', 3: 'Joy'}
4. Nested Dictionary
Image
P.S Sourceis -created
: The content Internet
by Rahul Trisal and copyrighted
Python Basics–Refresher
5. Sample Example from Boto3
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/client/list_buckets.html#
• Lists in Python can be created by just placing the sequence inside the square brackets []
• A single list may contain Data Types like Integers, Strings, as well as Objects.
• List in Python are ordered and have a definite count. The elements in a list are indexed with 0 being the first index.
• slice(start, stop, step)
• Reverse [ : : -1]
………………………………………………
list = [1, 4, 'For', 6, 'Anisha’]
……………………………………………….
7. Nested List
Nested List => nestedList = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/client/list_buckets.html#
Example
# A simple Python function to check whether x is even or odd
def evenOdd(x):
if (x % 2 == 0):
print("even")
else:
print("odd")
# Driver code to call the function
evenOdd(2)
evenOdd(3) P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
Section 4
AWS Lambda – Create S3, EC2 and DynamoDB
resources using Lambda (Boto3)
Section 4: AWS Lambda – Create S3, EC2 and DynamoDB resources using Lambda (Boto3)
• AWS Lambda with S3 (Create new Bucket , List all the Buckets and Delete Bucket)
S3 EC2 DynamoDB
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda Hands on - Basics of Lambda Function
AWS SDK for Python (Boto3)
• Boto3 library makes it easy to integrate with AWS services including Amazon S3, Amazon EC2, Amazon DynamoDB, and more using
Python.
Client APIs
Resource APIs
The Lambda function handler is the method in your function code that processes events. When your function is invoked, Lambda runs the handler method.
• invoked_function_arn – The Amazon Resource Name (ARN) that's used to invoke the function. Indicates if the invoker specified a version number or alias.
• identity – (mobile apps) Information about the Amazon Cognito identity that authorized the request.
• cognito_identity_pool_id – The Amazon Cognito identity pool that authorized the invocation.
• client_context – (mobile apps) Client context that's provided to Lambda by the client application.
• client.installation_id
• client.app_title
• client.app_version_name
• client.app_version_code
• client.app_package_name
S3
- List the inventory of all the S3 buckets in the Organization AWS Account (Sandbox, Dev etc.)
EC2
EC2
- Start EC2 Instance
EventBridge
• Event Source ------ > EventBridge (Evaluate Rule) ------- > Event Target and Action
• Schedule Events
Source : AWS
DynamoDB
• Architecture - x86_64
• Create Function
• Go to Configuration --- > General Configuration --- > Change Timeout limit to – 1 min
• Go to Configuration --- > Permission--- > Click on Role name --- > Add Permission
• Response parameters
• Print the response based on type (Dictionary and so) using print function
Section on
AWS Lambda – Basic Concepts (Part 2)
Get Method
Source : AWS
Review Invocation
with CloudWatch Logs
• Lambda runs your code for a set amount of time before timing out.
• When the specified timeout is reached, Amazon Lambda terminates execution of your Lambda function.
Best Practice:
• Performance and cost are two key parameters for setting the Timeout limit
• Edge Cases can impact cost P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
Section on
Real World Serverless Use Case 1 - using S3, AWS
Lambda and DynamoDB
- s3demo01022022abc
DynamoDB Table
- RetailSales02032022
- CustomerID
- Product
Very Important :
Please change the name of the S3 Bucket and DynamoDB Table with your own and substitute the names in the Lambda Python Code.
P.S : Theunique
The S3 bucket names need to be globally content isand
created
sameby Rahul
namesTrisalthat
and copyrighted
were highlighted in the video will not work.
AWS Lambda and Python – Beginner to Advanced
Section on
API Gateway Overview
Amazon API Gateway is an AWS service for creating, publishing, maintaining, monitoring, and securing REST,
1. API Types
1. HTTP API
Build low-latency and cost-effective REST APIs with built-in features such as OIDC and OAuth2, and native CORS support.
2. WebSocket API
Build a WebSocket API using persistent connections for real-time use cases such as chat applications or dashboards.
3. REST API
Develop a REST API where you gain complete control over the request and response along with API management capabilities.
https://aws.amazon.com/blogs/compute/introducing-amazon-api-gateway-private-endpoints/
P.S : The content is created by Rahul Trisal and copyrighted
AWS API Gateway - Overview
Key Features of API Gateway
• REST APIs support more features than HTTP APIs, while HTTP APIs are designed with minimal features and offered at a lower price.
• Choose REST APIs if you need features such as API keys, per-client throttling, request validation, AWS WAF integration, or private API
endpoints.
• Choose HTTP APIs if you don't need the features included with REST APIs.
• https://aws.amazon.com/blogs/compute/introducing-amazon-api-gateway-private-endpoints/
Private
Source
P.S ::The
AWScontent is created by Rahul Trisal and copyrighted
API Gateway - Overview
3. Resources
4. Methods
Method Description
Retrieve information about the
GET
REST API resource
POST Create a REST API resource
PUT Update a REST API resource
Delete a REST API resource or
DELETE
related component
Lambda Function
HTTP
• This type of integration lets an API expose HTTP endpoints in the backend.
Mock
• This type of integration lets API Gateway return a response without sending the request further to the backend.
AWS Service
VPC Link
A VPC link is a resource in Amazon API Gateway that allows for connecting API routes to private resources inside a VPC
After creating your API, you must deploy it to make it callable by your users.
To deploy an API, you create an API deployment and associate it with a stage.
Important Tip :
Every time you update an API, you must redeploy the API to an existing stage or to a new stage.
Updating an API includes modifying routes, methods, integrations, authorizers, and anything else other than stage settings.
6. Stages
A logical reference to a lifecycle state of your API (for example, 'dev', 'prod', 'beta', 'v2’).
https://{restapi-id}.execute-api.{region}.amazonaws.com/{stageName}
https://ent94mc14j.execute-api.us-east-1.amazonaws.com/dev/students
P.S : The content is created by Rahul Trisal and copyrighted
API Gateway - Overview
7. AWS API Gateway - Authentication and Authorization
Authentication – IAM
Authorization – IAM Policy
Authentication – External
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
P.S : The content is created by Rahul Trisal and copyrighted
API Gateway - Overview
8. Usage Plans
Usage Plans
Sets the target request rate - Throttling, Burst and Quota Limit for each API Key
9. API Keys
• An alphanumeric string that API Gateway uses to identify an app developer who uses your REST or WebSocket API.
• You can use API keys together with Lambda authorizers or usage plans to control access to your APIs.
Private API’s
A private API means that the API endpoint is reachable only through the VPC. Private APIs are accessible only from
clients within the VPC or from clients that have network connectivity to the VPC.
Private Integration
An API Gateway integration type for a client to access resources inside a customer's VPC through a private REST
API endpoint without exposing the resources to the public internet.
Source : https://aws.amazon.com/blogs/compute/understanding-vpc-links-in-amazon-api-gateway-private-integrations/
P.S : The content is created by Rahul Trisal and copyrighted
API Gateway - Overview
10. API Integration and Private API’s
Source : AWS P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
Section on
Real World Serverless Use Case 2 - using API Gateway,
AWS Lambda and S3
• S3 buckets – 2
• Lambda Function
• API Gateway
Very Important :
Please change the name of the S3 Bucket with your own and substitute the names in the Lambda Python Code.
The S3 bucket names need to be globally unique and same names that were highlighted in the video will not work.
AWS Lambda and Python – API Keys
API Keys
• API keys are alphanumeric string values that you distribute to application developer customers to grant access to your API.
• API Gateway can generate API keys on your behalf or import it into API Gateway from an external source.
• API Key can be used along with Usage Plan for Throttling and Quotas to differentiate between Basic and Premium Users
• You can use API keys together with Lambda authorizers or usage plans to control access to your APIs.
• Don't use API keys for authentication or authorization for your APIs.
• Instead, use an IAM role, a Lambda authorizer, or an Amazon Cognito user pool.
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Throttling and Quota
Throttling Limit
• API throttling is the process of limiting the number of API requests a user can make in a certain period.
Quota
• Quota limit sets the target maximum number of requests with a given API key that can be submitted within a specified time
interval.
• Throttling and quota limits apply to requests for individual API keys that are aggregated across all API stages within a usage plan
• Sets the target request rate - Throttling, Burst and Quota Limit for each API Key
• Specifies who can access one or more deployed API stages and methods through the API Keys
API Key -- >Usage Plan --- > Throttling, Burst and Quota ---- >Set at [API --- > Deployment Stage -- > Resources -- > Method ]
1. Basic Plan
• Throttling Limit – 5 Requests/Second
• Burst – 2 Requests/Second
• Quota – 150 Requests/Month
• API (Resource – Students, Method – GET)
• Stage – Beta
• API Key – x-api-key = xyz
2. Premium Plan
• Throttling Limit – 50 Requests/Second
• Burst – 20 Requests/Second
• Quota – 1500 Requests/Month
• API(Resource – Students, Method – GET)
• Stage – Prod
• API Key - abc
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Usage Plans
Steps to configure a usage plan
• Generate or import API keys to distribute to application developers (your customers) who will be using your API.
• Create the usage plan with the desired throttle and quota limits.
• Associate API stages and API keys with the usage plan.
• Callers of the API must supply an assigned API key in the x-api-key header in requests to the API.
Section on
API Security - Securing API's with AWS Lambda
Authorizer & Cognito Authorizer
Authentication – IAM
Authorization – IAM Policy
Authentication – External
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda Authorizer
AWS API Gateway - Authentication and Authorization using Lambda Authorizer
Lambda Authorizer
Authentication – External
Authorization – Lambda
Function
3. Resource - students
4. Method - GET
7. Create the Authorizer in the API Gateway Console (Authorization Token : Key – authorizationToken, Value - 123456)
• Amazon Cognito is a developer-centric and cost-effective customer identity and access management (CIAM) service.
• Provides a secure identity store and federation options that can scale to millions of users.
• Amazon Cognito supports login with social identity providers and SAML or OIDC-based identity providers
• Supports various compliance standards, operates on open identity standards (OAuth2.0, SAML 2.0 and OpenID Connect)
• Self-registration of users
• Policy Enforcement
Section on
AWS Generative AI :
AWS Bedrock , API Gateway, and AWS Lambda
2 3
Custom Application Sends the detailed issue log
Images
Summary of issue log
Detailed
Issue Logs 4
AWS Bedrock
1
Incident Report
Generative AI – Use Case Architecture
2. Models Supported
4. Upgrade the boto3 version for AWS Lambda Function using Lambda Layer -
https://repost.aws/knowledge-center/lambda-python-runtime-errors
• Link - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime.html
#2. Create a Request Syntax - Get details from console and body should be json object
#4 a. Print the event , b. Store the input in a variable, c. Update the response body
• Resource – demoBedrock
• Method - GET
• application/json
"prompt" : "$input.params('prompt')"
Section on
Lambda Advanced Concepts
• Lambda Versions
• Lambda Aliases
Source : AWS
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
AWS Lambda Concurrency
• Concurrency is the number of in-flight requests your AWS Lambda function is handling at the same time.
• For each concurrent request, Lambda provisions a separate instance of your execution environment.
• As the functions receive more requests, Lambda automatically handles scaling the number of execution
• By default, Lambda provides account with a total concurrency limit of 1,000 across all functions in a region.
Source : AWS
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
AWS Lambda Concurrency
Source : AWS
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
AWS Lambda - Concurrency
• Concurrency Implication :
• A concurrency of 50 means that Lambda must provision 50 execution environment instances to efficiently
handle this workload without any throttling.
Source : AWS
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
Provisioned Concurrency and Reserved Concurrency
Provisioned Concurrency
• Use provisioned concurrency to pre-initialize a number of environment instances for a function. This is useful
for reducing cold start latencies.
Source : AWS
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
Reserved concurrency vs. Provisioned concurrency
Reserved Concurrency
• Use reserved concurrency to reserve a portion of your account's concurrency for a function. This is useful if
you don't want other functions taking up all the available unreserved concurrency.
P.S : The content is created by Rahul Trisal and copyrighted Source : AWS
AWS Lambda and Python – Beginner to Advanced
Provisioned concurrency vs Reserved concurrency
Source : AWS
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
AWS Lambda Limits - Memory
Best Practice
• Derive the balance between Function Time out and Memory allocated (think about the edge cases)
• Over-Provision Memory, If required but Not Function Timeout
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
AWS Lambda Limits - Memory
Chart based on per 1000 Invocations
Best Practice
• Derive the balance between Function Time out and Memory allocated (think about the edge cases)
• Over-Provision Memory, If required but Not Function Timeout
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
AWS Lambda – Deployment Options – Default and VPC Private Resources
Where is AWS Lambda Deployed – Option 1
S3 DynamoDB
• All Lambda functions run securely inside a default system-managed virtual private cloud (VPC).
• Not in Customer VPC
• Has access to all the services that P.S
can becontent
: The accessed
is createdon Internet
by Rahul – S3,
Trisal and DynamoDB etc.
copyrighted
AWS Lambda and Python – Beginner to Advanced
AWS Lambda Deployment and access to Private Subnet Resources
How does Lambda access AWS Services in Customer VPC in Private Subnet such as RDS DB or EC2
Private Subnet
Private Subnet
• Lambda need the IAM permissions required to create and delete network interfaces in your VPC - AWSLambdaVPCAccessExecutionRole
• Control the subnet and security group configurations of these network interfaces.
• Use a NAT device to give a function internet access or use VPC endpoints to connect to services outside of your VPC.
How does Lambda access AWS Services in Customer VPC in Private Subnet – Option 2
How does Lambda access AWS Services in Customer VPC in Private Subnet – Option 2
Using Hyperplane (the Network Function Virtualization platform ) ENI, a managed network resource that the Lambda
service controls, allowing multiple execution environments to securely access resources inside of VPCs in your account.
Managed under the hood by AWS but need to be aware of configuration settings –
P.S : TheLambda
Whether content is created
accessesby Rahul Trisalor
Public and copyrighted
Private Resources
AWS Lambda and Python – Beginner to Advanced
AWS Lambda Monitoring – Use CloudWatch Metrics, Logs and Dashboard
• Lambda service automatically monitors Lambda functions and sends function Metrics and Logs to CloudWatch.
• On processing an event, Lambda sends metrics about the invocation to CloudWatch and generate logs.
• Graphs and dashboards can be built with these metrics on the CloudWatch console
Get Method
Sample Event
{ "bucket": "firstbucket01092022", "key": "bucket1.json"}
1. Invocations: The number of times that your function code is invoked, including successful invocations and
invocations that result in a function error.
2. Duration: The amount of time that your function code spends processing an event.
4. Throttles: Set alarms on this metric for any non-zero value since this only occurs if the number of
invocations exceeds concurrency in your account.
5. ConcurrentExecutions: monitor this value to ensure that your functions are not running close to the total
concurrency limit for your AWS account.
6. UnreservedConcurrentExecutions: Similar to the previous metric but excludes functions using reserved
concurrency.
7. DeadLetterErrors: An error is triggered if Lambda cannot write to the designated dead-letter queue, set
alarm on any non-zero values for this metric.
8. IteratorAge: For Lambda functions that poll streaming sources, such as Kinesis or DynamoDB streams, the
value indicates when events are being produced faster than they are being consumed by Lambda.
IteratorAge is the difference between the current time and when the last record of the GetRecords call was
written to the stream.
• Lambda function comes with a CloudWatch Logs log group (/aws/lambda/function name) and a log stream for
• The Lambda runtime environment sends details about each invocation to the log stream, and relays logs and
• To output logs from your function code, use the print method, or any logging library that writes to stdout or
stderr.
1. RequestId
2. Duration
3. Billed Duration
• For example, you can publish a new version of a function in Dev, QA and Prod
• Lambda creates a new version of your function each time we publish the function.
• A unique Amazon Resource Name (ARN) to identify the specific version of the function.
P.S : The content is created by Rahul Trisal and copyrighted
AWS Lambda and Python – Beginner to Advanced
AWS Lambda Aliases
• Users can access the function version using the alias Amazon Resource Name (ARN).
• Each alias has a unique ARN. An alias can point only to a function version, not to another alias.
• Event sources such as Amazon Simple Storage Service (Amazon S3) invoke your Lambda function. These event
sources maintain a mapping that identifies the function to invoke when events occur. If you specify a
Lambda function alias in the mapping configuration, you don't need to update the mapping when the
function version changes.
• In a resource policy, you can grant permissions for event sources to use your Lambda function. If you specify
an alias ARN in the policy, you don't P.S
need to update
: The content is createdthe policy
by Rahul when
Trisal and the function version changes.
copyrighted
AWS Lambda and Python – Beginner to Advanced
AWS Lambda – Environment Variables
• Environment variables can be used to adjust your function's behavior without updating code.
• Most common use case is storing and retrieving hostname and other connection details for the database in test and prod
environments
• Environment variable for your function can be defined by using a key and a value.
• The Lambda runtime makes environment variables available to your code.
• Your function uses the name of the key to retrieve the value of environment variable.
Section on
Serverless Use Case-using API Gateway, AWS Lambda
and S3 (Balance Status Application)
Check using open Start -- > cmd -- > Run following command > aws - - version; output : aws-cli/2.7.24…
In case of error : Run following command >> “Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass” and then execute other commands
P.S : The content is created by Rahul Trisal and copyrighted
AWS CDK v2 – Pre-Requisites
5. Install Node.js - https://nodejs.org/en/ (Check by running following command >> node - - version,
output should be > v10.3.0)
6. AWS Account User - Configure Credentials to access AWS services from Visual Studio -
https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/establish-credentials.html
• Configure Credentials
• Test using following command If configured properly – > aws s3 ls (should return all s3 buckets)
https://cdkworkshop.com/15-prerequisites/100-awscli.html
P.S : The content is created by Rahul Trisal and copyrighted
AWS Cloud Development Kit (CDK) v2 – Serverless Use Case
Serverless Use Case - using API Gateway, AWS Lambda and S3
• S3
• IAM Role
• AWS Lambda
• API Gateway
2. IAM Role
• roleName
• assumedBy
• description
• IAM Policy attached to Role - AmazonS3FullAccess
3. AWS Lambda
• handler - lambda_function.lambda_handler
• role
• code
• runtime
• LambdaCode file – lambda_function.py
P.S : The content is and
createdMethod
by Rahul Trisal–and
lambda_handler
copyrighted
AWS CDK v2 – Serverless Use Case
Serverless Use Case - using API Gateway, AWS Lambda and S3
4. API Gateway
• handler
• restApiName
• proxy
• deploy
• Resource - balanceStatus
• Method – GET
• Construct - LambdaRestAPI
Step 2. – Create the app: Create Infra & Services Folder - mkdir infra, mkdir services and cd infra
Step 3. – Initialize the CDK with cdk init app --language typescript
Step 4. – Import the module for aws service being created - Link
Step 5. – Define Scope, Logical ID and Props – (this, ’logical id’, {props})
Step 8. – Synthesize an AWS CloudFormation template for the app with cdk synth
Section on
AWS CloudFormation- API GW, Lambda, S3- (From my
Udemy Course on CloudFormation)
Source:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/t
emplate-anatomy.html
• S3
• IAM Role/Lambda
Execution Role
• AWS Lambda
• API Gateway
Account Balance Status
• LambdaInvokePermission
Section on
Real World Serverless Use Case 3 - Monitor & increase
free storage for SQL Server FCI Cluster
• Microsoft AD
• EC2
• FSx
• CloudWatch Metrics
• CloudWatch Alarm
2. Variable - Containers for storing data values string, float or integers and no need to declare; Syntax : x = 3, greeting = “hello” etc.
>> demo = "hi“
>> x = 30
>> grade = 4,
>> section = ‘A’
>> print(“My class is : {} and section is {}".format(grade, section))
P.S : The content is created by Rahul Trisal and copyrighted
Python Basics – 2 (Data Types Introduction)
5. Data Types Introduction
Data types are the classification or categorization of data items. It represents the kind of value that tells what operations
can be performed on a particular data.
• Numeric (Integer, Complex Number, Float)
• Dictionary – Most Important; Key-value pairs; Dict = {1: ‘Rahul', 2: ‘John', 3: ‘Joy’}
• Boolean (True or False)
• Set - Sets are used to store multiple items in a single variable; fruits = {"apple", "banana", "cherry"}
• Sequence Type (String, List and Tuple)
• Strings is a sequence of characters internally stored as binary (“Aaron”)
• ASCII value of the letter 'A' is 65.
• List - Lists in Python can be created by just placing the sequence inside the
square brackets[]
• [“Rahul”, “John”, “Joy”]
P.S : The content is created by Rahul Trisal and copyrighted Source : Internet
AWS Lambda with Python – Basics - 3
12. Function
Python Functions is a block of related statements designed to perform a computational, logical, or evaluative task.
Syntax:
def function_name(argument/parameters):
return expression or value
Example
# A simple Python function to check whether x is even or odd
def evenOdd(x):
if (x % 2 == 0):
print("even")
else:
print("odd")
# Driver code to call the function
evenOdd(2)
evenOdd(3)
• curly brackets
• key: pair values
• Its mutable but keys immutable
• Nested Dictionary
………………………………………………
d = {1: 'Python', 2: 'For', 3: 'Lambda'}
Nested Dictionary
nd = {1:'Python', 2:{'books’: 'arch’ , 'aws':'Lambda'}}
………………………………………………
• Items
• Keys
• Values
• Elements in Dictionary – Getting specific values from Key Names
• Elements in Dictionary – Getting specific values from Key Names in a Nested Dictionary
• Adding an element to dictionary - d[3] = "red"
P.S : The content is created by Rahul Trisal and copyrighted
• Dictionary Methods
Python Basics – 2 (Loops and Slicing)
7. Loop (for loop)
For loops are used for sequential traversal. For example: traversing a list or string or array etc.
>> data = “length”
Syntax :
>> for k in data :
print(k) -----> k, colon, spacing (4 or 5)
https://www.jetbrains.com/pycharm/download/#section=windows
https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-
order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all
Python Functions is a block of related statements designed to perform a computational, logical, or evaluative task.
Syntax:
def function_name(argument/parameters):
return expression or value
Example
# A simple Python function to check whether x is even or odd
def evenOdd(x):
if (x % 2 == 0):
print("even")
else:
print("odd")
# Driver code to call the function
evenOdd(2)
evenOdd(3)