Skip to content

team-tech-challenge/tech-challenge-register-confirm-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tech-challenge-register-confirm-lambda

Maintenance MIT License Terraform Terraform AWS Documentation Terraform Documentation GitHub

This repository contains Terraform modules for AWS resources.

Structure of the Repository

The repository is structured as follows:

./
|   .gitignore
|   Dockerfile
|   README.md
|
+---.github
|   \---workflows
|           deploy-project.yaml
|
+---iac
|   |   backend.tf
|   |   locals.tf
|   |   main.tf
|   |   output.tf
|   |   provider.tf
|   |   variables.tf
|   |   versions.tf
|   |
|   \---modules
|       \---generic
|               locals.tf
|               main.tf
|               output.tf
|               variables_aws_api_gateway.tf
|               variables_aws_cognito.tf
|               variables_aws_ecr_repository.tf
|               variables_aws_lambda_event_source_mapping.tf
|               variables_lambda_function.tf
|               variables_lambda_permission.tf
|               versions.tf
|
\---src
        lambda_function.py

Modules Generic

  • This generic module executes the download of remote modules from the repository terraform-modules-remotes.
    • The generic module is located in the directory ./iac/modules/generic.

Lambda Function

The lambda_function.py is an essential part of this repository, which contains Terraform modules for AWS resources. This function is responsible for confirming a user's registration in an Amazon Cognito User Pool by validating the confirmation code provided during the sign-up process.


Key Features Receives User Data: The function accepts an event containing the username and the confirmation code. Confirms User Registration: It uses the confirmation code to confirm the user's sign-up in Cognito. Handles Errors: Provides appropriate error messages if the confirmation fails.


How It Works Necessary Imports: Utilizes libraries such as boto3 for interacting with Cognito and hmac for generating an authentication hash. Calculates Secret Hash: Generates a secret hash using HMAC and SHA-256, which is required for the confirmation request. Event Handling: Processes the incoming event to extract user data. User Confirmation in Cognito: Attempts to confirm the user and returns a success or error response.


Example Usage: The event should follow this structure:

curl --location 'https://techchallenge.com.br/api/v1/confirmation/register' \
--header 'Content-Type: application/json' \
--data '{
    "username": "111.111.111.11",
    "confirmation_code": "216779"
}'

Common Errors:

Registration Issues: Any error during registration generates an appropriate error message.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •