Service - AWS Resource Management: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 269: Line 269:
* **Write Unit Tests:** Develop unit tests to cover various scenarios, ensuring all functions behave as intended.
* **Write Unit Tests:** Develop unit tests to cover various scenarios, ensuring all functions behave as intended.
* **Optimize Performance:** Monitor the performance of the functions and optimize as necessary for large-scale data processing.
* **Optimize Performance:** Monitor the performance of the functions and optimize as necessary for large-scale data processing.
[[Category:Backend services| AWS Resource Management]]

Revision as of 06:33, 23 December 2024

Overview

AWSResourceManagement is a comprehensive service designed to clear caches for functions used in other services, ensuring consistently high performance and reliability across the system. By systematically removing outdated data and reloading relevant configurations, this service helps maintain accurate, up-to-date information in each function it manages. Whether you need to integrate new settings or refresh existing components, AWSResourceManagement streamlines cache operations to enhance overall efficiency and stability throughout your infrastructure.

Introduction

The fambda function is a utility within the test123 service designed to process numerical data efficiently. It simplifies numerical operations, enhancing both performance and code maintainability.

Example

Example usage of the lambda function:

const result = await lambda.invokeAsync(
      event._izContext,
      lambdaSharedLib.lambdaFunctionName('Function', AWSRM),
      {
        "serviceTag": "YourServiceTagTarget",
        "functionName": "YourFunctionNameTarget"
      }
);

Lambda Functions

The AWS Resource Management service includes six lambda functions to clean up the cache:

AWSRMTestFunction

Description: Invokes an asynchronous AWS Lambda function.
Parameters:

  • serviceTag (string): Name of the ServiceTag.
  • functionName (string): Name of the function to invoke within the service.
{
  "serviceTag": "YourServiceTagTarget",
  "functionName": "YourFunctionNameTarget"
}

Output: CASE Success

{
  "status": "complete",
  "errorFounds": []
}

CASE Fail
CASE if YourFuntionNameTarget is missing in s3 LambdaFunctions.json‎
errorFounds return functionName

{
  "status": "error",
  "errorFounds": ["YourFuntionNameTarget"]
}

CASE LambdaFunctions.json is Missing in s3

{
  "status": "error",
  "errorFounds": ["LambdaFunctions.json not found"]
}

AWSRMTestFunctions

Description: This function invokes multiple Lambda functions per service to clear their caches and initiate cold starts, ensuring they reload the latest configurations. This enables efficient cache management and simultaneous updates across your services.
Parameters:

  • clearLambdaList (array of objects, required): List of services and their corresponding Lambda functions to invoke.
    • serviceTag (string, required): Name of the ServiceTag.
    • functionNames (string, required): Names of the functions to invoke within the service.
{
   "clearLambdaList":[
      {
         "serviceTag":"YourServiceTagTarget1",
         "functionNames":[
            "YourFuntionNameTarget1",
            "YourFuntionNameTarget2"
         ]
      },
      {
         "serviceTag":"YourServiceTagTarget2",
         "functionNames":[
            "YourFuntionNameTarget1"
         ]
      }
   ]
}

OUTPUT: CASE Success

{
  "status": "complete",
  "errorFounds": []
}

OUTPUT: CASE Fail
CASE if YourFuntionNameTarget is missing in s3 LambdaFunctions.json
errorFounds return functionName

{
  "status": "error",
  "errorFounds": ["YourFuntionNameTarget"]
}

CASE LambdaFunctions.json is Missing in s3

{
  "status": "error",
  "errorFounds": ["LambdaFunctions.json not found"]
}

OUTPUT: CASE anyone is successful

{
  "status": "complete",
  "errorFounds": ["YourFuntionNameTarget1"]
}

AWSRMTestService

Description: This function invokes Lambda functions to clear caches for all functions within a service, initiating cold starts to ensure they reload the latest configurations. This enables efficient cache management and simultaneous updates across the entire service.
Parameters:

  • serviceTag (string, required): Name of the ServiceTag.
{
  "serviceTag": "YourServiceTagTarget"
}

OUTPUT: CASE Success

{
  "status": "complete",
  "errorFounds": []
}

OUTPUT: CASE Fail
CASE if YourFuntionNameTarget is missing in s3 LambdaFunctions.json
errorFounds return functionName

{
  "status": "error",
  "errorFounds": ["YourFuntionNameTarget"]
}

CASE LambdaFunctions.json is Missing in s3

{
  "status": "error",
  "errorFounds": ["LambdaFunctions.json not found"]
}

OUTPUT: CASE anyone is successful
S3 LambdaFunctions Found FunctionName: ["YourFuntionNameTarget1", "YourFuntionNameTarget2"]
if YourFuntionNameTarget1 is fail and YourFuntionNameTarget2 is Success

{
  "status": "complete",
  "errorFounds": ["YourFuntionNameTarget1"]
}

AWSRMTestServices

Description: This function invokes Lambda functions to clear caches for all functions within multiple services, initiating cold starts so they reload the latest configurations. This enables efficient cache management and simultaneous updates across all specified services.
Parameters:

  • clearLambdaList (array of objects, required): List of services and their corresponding Lambda functions to invoke.
    • serviceTag (array of strings, required): Names of the ServiceTags.
{
  "clearLambdaList": {
    "serviceTags": [
      "YourServiceTagTarget1",
      "YourServiceTagTarget2"
    ]
  }
}

OUTPUT: CASE Success

{
  "status": "complete",
  "errorFounds": []
}

OUTPUT: CASE Fail
CASE YourServiceTagTarget1 & YourServiceTagTarget2 is missing LambdaFunctions.json in s3

{
	"status": "error",
  "errorFounds": [
  "LambdaFunctions not found for service tag: service1",
  "LambdaFunctions not found for service tag: service2"
  ]
}

Error detected in the following functions:
* Function: YourFunctionNameTarget1 (Service: YourServiceTagTarget1)
* Function: YourFunctionNameTarget2 (Service: YourServiceTagTarget2)

{
  "status": "error",
  "errorFounds": ["ํYourFunctionNameTarget1", "YourFunctionNameTarget2"]
}

OUTPUT: CASE anyone is successful
Error detected in the following functions:
* Function: YourFunctionNameTarget1 (Service: YourServiceTagTarget1)
* Function: YourFunctionNameTarget2 (Service: YourServiceTagTarget2)
* if YourFuntionNameTarget1 is fail and YourFuntionNameTarget2 is Success

{
  "status": "complete",
  "errorFounds": ["YourFuntionNameTarget1"]
}

AWSRMTestAddAllRole

Description: This function is invoked without input. Upon invocation, it retrieves all roles from each service’s LambdaFunction.json and adds them to the functions AWSRMTestFunctionAWSRMTestFunctionsAWSRMTestService, and AWSRMTestServices for cache clearing. This process ensures the necessary roles are granted to perform cache-clearing tasks effectively.

AWSRMTestAddAllRole

Description: This function is invoked without input. Upon invocation, it retrieves all roles from each service’s LambdaFunction.json and adds them to the functions AWSRMTestFunctionAWSRMTestFunctionsAWSRMTestService, and AWSRMTestServices for cache clearing. This process ensures the necessary roles are granted to perform cache-clearing tasks effectively.
Parameters:

  • clearLambdaList: (array of objects, required): Specifies which services to process for role addition.
    • serviceTags (array of strings, required): Identifies the services from which roles will be added to AWSRMTestFunctionAWSRMTestFunctionsAWSRMTestService, and AWSRMTestServices for cache-clearing capabilities.
{
  "clearLambdaList": {
    "serviceTags": [
      "YourServiceTagTarget1",
      "YourServiceTagTarget2"
    ]
  }
}

OUTPUT: CASE Success

{
  "status": "complete",
  "errorFounds": []
}

OUTPUT: CASE Fail
CASE Not Found LambdaFunctions.json

{
	"status": "error",
  "errorFounds": [
  "LambdaFunctions.json not found for serviceTag: YourServiceTagTarget1",
  "LambdaFunctions.json not found for serviceTag: YourServiceTagTarget2"
  ]
}

CASE Can't CleanCacha After AddRole
* Function: YourFunctionNameTarget1 (Service: YourServiceTagTarget1)
* Function: YourFunctionNameTarget2 (Service: YourServiceTagTarget2)

{
  "status": "error",
  "errorFounds": ["ํLambdaService.clearCacheAll failed"]
}

OUTPUT: CASE anyone is successful
CASE Found YourServiceTagTarget1 is not Found LambdaFunctions.json

{
  "status": "complete",
  "errorFounds": ["LambdaFunctions.json not found for serviceTag: YourServiceTagTarget1"]
}

Best Practices

  • **Validate Inputs:** Always ensure that the input provided to the fambda and lambda functions is of the expected type and within acceptable ranges.
  • **Handle Exceptions:** Implement error handling to manage unexpected inputs or failures gracefully.
  • **Write Unit Tests:** Develop unit tests to cover various scenarios, ensuring all functions behave as intended.
  • **Optimize Performance:** Monitor the performance of the functions and optimize as necessary for large-scale data processing.