# Lambda code examples for the SDK for Ruby ## Overview Shows how to use the AWS SDK for Ruby to work with AWS Lambda. _Lambda allows you to run code without provisioning or managing servers._ ## ⚠ Important * Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/). * Running the tests might result in charges to your AWS account. * We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege). * This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). ## Code examples ### Prerequisites For prerequisites, see the [README](../../README.md#Prerequisites) in the `ruby` folder. ### Get started - [Hello Lambda](hello/hello_lambda.rb#L4) (`ListFunctions`) ### Basics Code examples that show you how to perform the essential operations within a service. - [Learn the basics](lambda_basics.rb) ### Single actions Code excerpts that show you how to call individual service functions. - [CreateFunction](lambda_basics.rb#L131) - [DeleteFunction](lambda_basics.rb#L281) - [GetFunction](lambda_basics.rb#L114) - [Invoke](lambda_basics.rb#L166) - [ListFunctions](lambda_basics.rb#L266) - [UpdateFunctionCode](lambda_basics.rb#L241) - [UpdateFunctionConfiguration](lambda_basics.rb#L216) ## Run the examples ### Instructions The quickest way to interact with this example code is to invoke a [Scenario](#Scenarios) from your command line. For example, `ruby some_scenario.rb` will invoke `some_scenario.rb`. #### Hello Lambda This example shows you how to get started using Lambda. ``` ruby hello/hello_lambda.rb ``` #### Learn the basics This example shows you how to do the following: - Create an IAM role and Lambda function, then upload handler code. - Invoke the function with a single parameter and get results. - Update the function code and configure with an environment variable. - Invoke the function with new parameters and get results. Display the returned execution log. - List the functions for your account, then clean up resources. Start the example by running the following at a command prompt: ``` ruby lambda_basics.rb ``` ### Tests ⚠ Running tests might result in charges to your AWS account. To find instructions for running these tests, see the [README](../../README.md#Tests) in the `ruby` folder. ## Contribute Code examples thrive on community contribution. To learn more about the contributing process, see [CONTRIBUTING.md](../../../CONTRIBUTING.md). ## Additional resources - [Lambda Developer Guide](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) - [Lambda API Reference](https://docs.aws.amazon.com/lambda/latest/dg/API_Reference.html) - [SDK for Ruby Lambda reference](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Lambda.html) --- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0