AWS Lambda - Developer Guide
AWS Lambda
Developer Guide
AWS Lambda Developer Guide
AWS Lambda: Developer Guide
Copyright ? 2022 Amazon Web Services, Inc. and/or its affiliates. All rights reserved. Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who may or may not be affiliated with, connected to, or sponsored by Amazon.
AWS Lambda Developer Guide
Table of Contents
What is AWS Lambda? ........................................................................................................................ 1 When to use Lambda ................................................................................................................. 1 Lambda features ........................................................................................................................ 2 Getting started with Lambda ....................................................................................................... 2
Getting started .................................................................................................................................. 4 Prerequisites .............................................................................................................................. 4 Create a function ....................................................................................................................... 5 Invoke the function .................................................................................................................... 5 Clean up ................................................................................................................................... 6 Additional resources ................................................................................................................... 7 Accessing Lambda ...................................................................................................................... 7 Authoring and deploying functions .............................................................................................. 7
Lambda foundations ........................................................................................................................... 9 Concepts ................................................................................................................................. 10 Function .......................................................................................................................... 10 Trigger ............................................................................................................................ 10 Event .............................................................................................................................. 10 Execution environment ...................................................................................................... 11 Instruction set architecture ................................................................................................ 11 Deployment package ........................................................................................................ 11 Runtime .......................................................................................................................... 11 Layer .............................................................................................................................. 12 Extension ........................................................................................................................ 12 Concurrency ..................................................................................................................... 12 Qualifier .......................................................................................................................... 12 Destination ...................................................................................................................... 13 Features .................................................................................................................................. 14 Scaling ............................................................................................................................ 14 Concurrency controls ........................................................................................................ 15 Function URLs .................................................................................................................. 16 Asynchronous invocation ................................................................................................... 16 Event source mappings ..................................................................................................... 17 Destinations ..................................................................................................................... 17 Function blueprints ........................................................................................................... 18 Testing and deployment tools ............................................................................................ 18 Application templates ....................................................................................................... 19 Programming model ................................................................................................................. 20 Architectures ............................................................................................................................ 21 Advantages of using arm64 architecture ............................................................................. 21 Function migration to arm64 architecture ........................................................................... 21 Function code compatibility with arm64 architecture ............................................................ 21 Suggested migration steps ................................................................................................ 22 Configuring the instruction set architecture ......................................................................... 22 Execution environment .............................................................................................................. 24 Runtime environment lifecycle ........................................................................................... 24 Networking .............................................................................................................................. 27 VPC network elements ...................................................................................................... 27 Connecting Lambda functions to your VPC .......................................................................... 28 Lambda Hyperplane ENIs .................................................................................................. 28 Connections ..................................................................................................................... 29 Security ........................................................................................................................... 29 Observability ................................................................................................................... 30 Deployment packages ............................................................................................................... 31 Container images ............................................................................................................. 31
iii
AWS Lambda Developer Guide
.zip file archives ............................................................................................................... 31 Layers ............................................................................................................................. 32 Using other AWS services .................................................................................................. 32 Lambda console ....................................................................................................................... 34 Applications ..................................................................................................................... 34 Functions ........................................................................................................................ 34 Code signing .................................................................................................................... 34 Layers ............................................................................................................................. 34 Edit code using the console editor ...................................................................................... 34 Lambda CLI ............................................................................................................................. 41 Prerequisites .................................................................................................................... 41 Create the execution role .................................................................................................. 41 Create the function .......................................................................................................... 42 Update the function ......................................................................................................... 45 List the Lambda functions in your account .......................................................................... 45 Retrieve a Lambda function ............................................................................................... 46 Clean up ......................................................................................................................... 46 Permissions ..................................................................................................................................... 47 Execution role .......................................................................................................................... 48 Creating an execution role in the IAM console ...................................................................... 48 Grant least privilege access to your Lambda execution role .................................................... 49 Managing roles with the IAM API ....................................................................................... 49 Session duration for temporary security credentials .............................................................. 50 AWS managed policies for Lambda features ........................................................................ 50 Working with Lambda execution environment credentials ...................................................... 52 User policies ............................................................................................................................ 55 Function development ...................................................................................................... 55 Layer development and use ............................................................................................... 58 Cross-account roles ........................................................................................................... 59 Condition keys for VPC settings ........................................................................................ 59 Control access using tags .......................................................................................................... 60 Prerequisites .................................................................................................................... 60 Step 1: Require tags ......................................................................................................... 60 Step 2: Control actions using tags ...................................................................................... 61 Step 3: Grant list permissions ............................................................................................ 61 Step 4: Grant IAM permissions ........................................................................................... 62 Step 5: Create the IAM role ............................................................................................... 62 Step 6: Create the IAM user ............................................................................................... 62 Step 7: Test the permissions .............................................................................................. 63 Resource-based policies ............................................................................................................. 64 Granting function access to AWS services ............................................................................ 65 Granting function access to an organization ........................................................................ 66 Granting function access to other accounts .......................................................................... 66 Granting layer access to other accounts .............................................................................. 68 Cleaning up resource-based policies .................................................................................... 68 Resources and conditions .......................................................................................................... 70 Policy conditions .............................................................................................................. 71 Function resource names ................................................................................................... 71 Function actions ............................................................................................................... 73 Event source mapping actions ............................................................................................ 75 Layer actions ................................................................................................................... 75 Permissions boundaries ............................................................................................................. 77 Lambda runtimes ............................................................................................................................. 79 Runtime deprecation policy ....................................................................................................... 80 Runtime modifications .............................................................................................................. 83 Language-specific environment variables ............................................................................. 83 Wrapper scripts ................................................................................................................ 85
iv
AWS Lambda Developer Guide
Custom runtimes ...................................................................................................................... 88 Using a custom runtime .................................................................................................... 88 Building a custom runtime ................................................................................................ 88
Runtime API ............................................................................................................................ 90 Next invocation ................................................................................................................ 90 Invocation response .......................................................................................................... 91 Initialization error ............................................................................................................. 91 Invocation error ............................................................................................................... 92
Tutorial ? Custom runtime ......................................................................................................... 95 Prerequisites .................................................................................................................... 95 Create a function ............................................................................................................. 95 Create a layer .................................................................................................................. 97 Update the function ......................................................................................................... 98 Update the runtime .......................................................................................................... 99 Share the layer ................................................................................................................ 99 Clean up ......................................................................................................................... 99
AVX2 vectorization ................................................................................................................. 101 Compiling from source .................................................................................................... 101 Enabling AVX2 for Intel MKL ............................................................................................ 101 AVX2 support in other languages ..................................................................................... 101
Lambda extensions ......................................................................................................................... 103 Execution environment ............................................................................................................ 103 Impact on performance and resources ....................................................................................... 104 Permissions ............................................................................................................................ 104 Configuring extensions ............................................................................................................ 105 Configuring extensions (.zip file archive) ............................................................................ 105 Using extensions in container images ................................................................................ 105 Next steps ..................................................................................................................... 105 Extensions partners ................................................................................................................ 107 AWS managed extensions ................................................................................................ 107 Extensions API ....................................................................................................................... 108 Lambda execution environment lifecycle ........................................................................... 109 Extensions API reference ................................................................................................. 117 Telemetry API ........................................................................................................................ 122 Creating extensions using the Telemetry API ...................................................................... 123 Registering your extension ............................................................................................... 125 Creating a telemetry listener ............................................................................................ 125 Specifying a destination protocol ..................................................................................... 126 Configuring memory usage and buffering .......................................................................... 127 Sending a subscription request to the Telemetry API ........................................................... 128 Inbound Telemetry API messages ..................................................................................... 128 API reference ................................................................................................................. 131 Event schema reference ................................................................................................. 134 Converting events to OTel Spans ...................................................................................... 147 Logs API ........................................................................................................................ 151
Deploying functions ........................................................................................................................ 160 .zip file archives ..................................................................................................................... 160 Container images .................................................................................................................... 160 .zip file archives ..................................................................................................................... 161 Creating the function ...................................................................................................... 161 Using the console code editor .......................................................................................... 162 Updating function code ................................................................................................... 162 Changing the runtime or runtime version .......................................................................... 163 Changing the architecture ............................................................................................... 163 Using the Lambda API .................................................................................................... 163 AWS CloudFormation ...................................................................................................... 164 Container images .................................................................................................................... 165
v
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- built in functions
- a tutorial introduction to the lambda calculus
- working with functions using python
- python the full monty
- lecture 09 filter map reduce and lambda
- 1 functions in python
- ppyytthhoonn ffuunnccttiioonnss tutorialspoint
- booleans if loops lambda functions
- tutorial 6 introduction to lambda iii serverless databases
- big data tutorial w2 spark
Related searches
- salesforce platform developer 2 certificati
- salesforce lightning developer guide
- aws python lambda function examples
- aws lambda python event object
- aws lambda pip install
- aws lambda package python
- microsoft visual web developer express
- business developer job description
- aws lambda doc
- developer tools microsoft word
- salesforce developer edition
- salesforce developer edition org