Lambda function to start nodes

AWS Lambda is a stateless compute service that lets you run code without provisioning or managing servers.

IBM Spectrum Scale stack leverages the Lambda function to start compute or server nodes. The mmaws create_lambda_functions command create a Lambda function which helps to start all the nodes, even if all or some of the nodes in the cluster are in a Stopped state.

Consider the following before creating a Lambda function:
  • The mmaws create_lambda_functions command creates a Lambda function start_nodes in the region where the IBM Spectrum Scale stack is deployed. This function needs to be created prior to stopping all nodes.
  • The Lambda function creation requires the presence of a role with AWSLambdaBasicExecutionRole policy as prerequisite. For more information on IAM role creation, see Create the Execution Role (IAM Role)
  • The Lambda function is created with the following parameters:
    • handler: lambda_handler
    • timeout: 300
    • memory_size: 128
  • AWS charges only for the compute time or Lambda function execution time, and there is no charge when this function is not running.
# mmaws create_lambda_functions --function-path /usr/lpp/mmfs/bin/ibm_aws_workflows/ibm_aws_lambda_funcs/mm_aws_lambda_start_nodes.py --iam-role Scale_lambda_exec_role
2019-04-04 13:22:06,977 - mm_aws_create_lambda_funcs - INFO - Logging in to file: /var/adm/ras/aws_scale_logs/mm_aws_create_lambda_funcs.log_2019-Apr-04_13-22-06
2019-04-04 13:22:06,977 - mm_aws_create_lambda_funcs - INFO - A. Performing prerequisite check
2019-04-04 13:22:06,978 - mm_aws_create_lambda_funcs - INFO - B. Performing current stack resource identification
2019-04-04 13:22:07,723 - mm_aws_create_lambda_funcs - INFO - Provided IAM role (Scale_lambda_exec_role) contains required "AWSLambdaBasicExecutionRole" policy.
2019-04-04 13:22:07,723 - mm_aws_create_lambda_funcs - INFO - C. Performing Lambda function vs. filepath mapping
2019-04-04 13:22:07,723 - mm_aws_create_lambda_funcs - INFO - Identified Lambda function(s) vs. filepath: {'start_nodes': '/usr/lpp/mmfs/bin/ibm_aws_workflows/ibm_aws_lambda_funcs/mm_aws_lambda_start_nodes.py'}
2019-04-04 13:22:07,723 - mm_aws_create_lambda_funcs - INFO - D. Performing Lambda function creation
2019-04-04 13:22:08,234 - mm_aws_create_lambda_funcs - INFO - Lambda function (start_nodes) created successfully.
Note: Scale_lambda_exec_role is the name of the IAM role. The user should provide the name of the IAM role which is created with the AWSLambdaBasicExecutionRole policy.
You can also run this CLI without a function-path as follows:
mmaws create_lambda_func --iam-role Scale_lambda_exec_role
This creates a Lambda function which can be viewed from the Lambda console.
Figure 1. Lambda console

The start_nodes is the new Lambda function created, and its function details can be viewed by clicking on start_nodes.
Figure 2. Viewing Lambda function details

The start_nodes function code can be viewed under the Function code tab.
Figure 3. Function code information

Function code information

The start_nodes function is populated with environment variables such as region and stack_para_ids. These variables are needed for the execution of the function.
Figure 4. Environment variables

Environment variables

The start_nodes function is populated with role, memory, and timeout information.
Figure 5. Environment variables

Environment variables

Note: This function can be executed by creating a test event.
Follow these steps to execute the Lambda function:
  1. Click on Test.
    Figure 6. Execute Lambda function

    Execute Lambda function

  2. In the Configure test event page, enter the event name of your choice and remove the existing key values shown in the curly braces. Click Create.
    Figure 7. Execute Lambda function

    Execute Lambda function

    Note: The event created in the previous step can be found in the Select test event box.
    Figure 8. Select test event

    Select test event

Important: The mmaws start_nodes command can also be used to start nodes. However, at least one node of the cluster must be running in order to start the other stopped nodes of the cluster using the mmaws start_nodes command.