SIGN IN SIGN UP

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

0 0 8 Java
# Lambda code examples for the SDK for Ruby
## Overview
2022-09-19 09:05:20 -06:00
Shows how to use the AWS SDK for Ruby to work with AWS Lambda.
<!--custom.overview.start-->
<!--custom.overview.end-->
2024-01-04 13:25:48 -05:00
_Lambda allows you to run code without provisioning or managing servers._
## ⚠ Important
2024-01-04 13:25:48 -05:00
* 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).
2022-09-19 09:05:20 -06:00
<!--custom.important.start-->
<!--custom.important.end-->
2022-09-19 09:05:20 -06:00
## Code examples
### Prerequisites
For prerequisites, see the [README](../../README.md#Prerequisites) in the `ruby` folder.
<!--custom.prerequisites.start-->
<!--custom.prerequisites.end-->
### Get started
- [Hello Lambda](hello/hello_lambda.rb#L4) (`ListFunctions`)
2024-10-24 09:34:43 -04:00
### 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)
2024-01-04 13:25:48 -05:00
<!--custom.examples.start-->
<!--custom.examples.end-->
## Run the examples
### Instructions
<!--custom.instructions.start-->
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`.
<!--custom.instructions.end-->
#### Hello Lambda
This example shows you how to get started using Lambda.
```
ruby hello/hello_lambda.rb
```
2024-10-24 09:34:43 -04:00
#### Learn the basics
2022-09-19 09:05:20 -06:00
This example shows you how to do the following:
2024-01-04 13:25:48 -05:00
- 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.
2024-10-24 09:34:43 -04:00
<!--custom.basic_prereqs.lambda_Scenario_GettingStartedFunctions.start-->
<!--custom.basic_prereqs.lambda_Scenario_GettingStartedFunctions.end-->
Start the example by running the following at a command prompt:
```
ruby lambda_basics.rb
```
2024-10-24 09:34:43 -04:00
<!--custom.basics.lambda_Scenario_GettingStartedFunctions.start-->
<!--custom.basics.lambda_Scenario_GettingStartedFunctions.end-->
2022-09-19 09:05:20 -06:00
### Tests
2022-09-19 09:05:20 -06:00
⚠ Running tests might result in charges to your AWS account.
2022-09-19 09:05:20 -06:00
To find instructions for running these tests, see the [README](../../README.md#Tests)
in the `ruby` folder.
2022-09-19 09:05:20 -06:00
<!--custom.tests.start-->
## Contribute
Code examples thrive on community contribution.
To learn more about the contributing process, see [CONTRIBUTING.md](../../../CONTRIBUTING.md).
<!--custom.tests.end-->
## Additional resources
2022-09-19 09:05:20 -06:00
2024-01-04 13:25:48 -05:00
- [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)
<!--custom.resources.start-->
<!--custom.resources.end-->
---
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0