lambda

module
v0.0.0-...-c73b962 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2024 License: Apache-2.0

README

Lambda code examples for the SDK for Go V2

Overview

Shows how to use the AWS SDK for Go V2 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 and Free Tier.
  • 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.
  • This code is not tested in every AWS Region. For more information, see AWS Regional Services.

Code examples

Prerequisites

For prerequisites, see the README in the gov2 folder.

Get started
Single actions

Code excerpts that show you how to call individual service functions.

Scenarios

Code examples that show you how to accomplish a specific task by calling multiple functions within the same service.

Run the examples

Instructions
Hello Lambda

This example shows you how to get started using Lambda.

go run ./hello
Run a scenario

All scenarios can be run with the cmd runner. To get a list of scenarios and to get help for running a scenario, use the following command:

go run ./cmd -h
Automatically confirm known users with a Lambda function

This example shows you how to automatically confirm known Amazon Cognito users with a Lambda function.

  • Configure a user pool to call a Lambda function for the PreSignUp trigger.
  • Sign up a user with Amazon Cognito.
  • The Lambda function scans a DynamoDB table and automatically confirms known users.
  • Sign in as the new user, then clean up resources.
Automatically migrate known users with a Lambda function

This example shows you how to automatically migrate known Amazon Cognito users with a Lambda function.

  • Configure a user pool to call a Lambda function for the MigrateUser trigger.
  • Sign in to Amazon Cognito with a username and email that is not in the user pool.
  • The Lambda function scans a DynamoDB table and automatically migrates known users to the user pool.
  • Perform the forgot password flow to reset the password for the migrated user.
  • Sign in as the new user, then clean up resources.
Get started with functions

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.
Write custom activity data with a Lambda function after Amazon Cognito user authentication

This example shows you how to write custom activity data with a Lambda function after Amazon Cognito user authentication.

  • Use administrator functions to add a user to a user pool.
  • Configure a user pool to call a Lambda function for the PostAuthentication trigger.
  • Sign the new user in to Amazon Cognito.
  • The Lambda function writes custom information to CloudWatch Logs and to an DynamoDB table.
  • Get and display custom data from the DynamoDB table, then clean up resources.
Tests

⚠ Running tests might result in charges to your AWS account.

To find instructions for running these tests, see the README in the gov2 folder.

Additional resources


Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL