Start project: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 96: Line 96:
# lambda_1 will invoke lambda_2 to get data that return to lambda_1  
# lambda_1 will invoke lambda_2 to get data that return to lambda_1  
## ex: lambda_1 => inv => lambda_2 => lambda_2 will return data => lambda_1
## ex: lambda_1 => inv => lambda_2 => lambda_2 will return data => lambda_1
code example:  
code example for use inv lambda:  
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
let payload = {
let payload = {

Revision as of 04:52, 19 October 2023

Start Project For Beginner

prepare project to local

  • BitBucket account.
  1. fork repository to own workspace
  2. clone repository to local
git clone git@bitbucket.org:your_repository_path.git
  • Local Computer add workspace in VS code.
  1. open VS Code => File/Add Folder to Workspace...
  2. choose your project
  • set SSH of BitBucket
  1. sudo apt update && sudo apt install openssh-client
  2. sudo dnf install openssh-clients
  3. ssh -V
  4. ssh-keygen -t ed25519 -b 4096 -C "{penpitcha4289@gmail.com}" -f {penpitcha_workspace}

add SSH key in key.pub that generate above into SSH of repository in BitBucket
https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-linux/

prepare resource and app

Example Data for project: https://izara.io/wiki/index.php/Service_-_Product_Manager

  • install package
example: in app

npm i @izara_project/izara-middleware
npm i @izara_project/izara-shared

//* install more see in package.json

Example:

set initial setup

in app/initial_setup

start deploy to AWS server

  • in config
  1. iz_serviceName for beginner test => Service{YourName} ex: ServicePraew => if your project => ProductManager
  2. iz_region for beginner test will use region => ap-southeast-2 //sydney => if your project will use region => us-east-2
  • Config credentials aws, can run on home directory
  1. check version
sls --version
aws --version
  • Install the AWS CLI version 2 (window)
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi

ref: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html

  • find Access Key and Secret Access Key

create Access key 1 from AWS server => User => your User Name

  • configuration
aws configure

show:

AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE  // ***YOUR ID
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY //***YOUR KEY
Default region name [None]: us-east-2 // Ohio
Default output format [None]: json
  • deploy repository

deploy resource before app

sls deploy --verbose

Test

Example request for test Api|Sqs|Dqs handler

Task

  • add Get|Delete|Update Product_Main Lambda for Api Handler
  • create lambda that send msg to each lambda in same service
  1. lambda => sns => sqs => lambda => maybe use handler Sqs
  2. lambda => sqs => lambda => maybe use handler Dsq
  • apply for use Inv Handler
  1. lambda_1 will invoke lambda_2 to get data that return to lambda_1
    1. ex: lambda_1 => inv => lambda_2 => lambda_2 will return data => lambda_1

code example for use inv lambda:

let payload = {
  param: param
}

let lambda_2Record = await lambda.invokeSync(
  _izContext,
  lambdaSharedLib.lambdaFunctionName("Lambda_2_HdrInv"), //externalServiceName if inv|send msg external service need to put service that get data
  payload
);