Extend Calculation Workflow

Extend Calculation Workflow

In the previous step, we manually deployed a Lambda function handler that simply added all operands together. In this step, we will add a new Lambda function that dispatches the operator based on its name, and also create a CI/CD pipeline to manage the deployment of the Lambda function. The Lambda function code we provide here will still only dispatch Addition - in a later Challenge Exercise, you will be tasked with implementing the other basic functions (multiplication, subtraction, division).

  1. Download file CalculatorStepAddition.zip to the Windows virtual machine and extract
  2. Go to AWS CodeStar Console.
  • Click Projects
  • Click Create project

    Click Create service role if you never go to AWS CodeStar Service before.

    Extend Calculation Workflow
  1. In the Templates section, select Java and AWS Lambda
  • Select Java Spring
  • Click Next Extend Calculation Workflow
  1. In the Project name section, type dev-calculator
  • Click Next Extend Calculation Workflow
  1. In the Review page, click Create project Extend Calculation Workflow
  2. In the Eclipse IDE, find the AWS Icon and click it to reveal the menu
  • Click Import AWS CodeStar Project… Extend Calculation Workflow
  1. Select region we use in this lab
  • Select project dev-calculator
  • Type the information of Git credentials
  • Click Next Extend Calculation Workflow
  1. Click OK
  • Click Next Extend Calculation Workflow
  1. Click Finish Extend Calculation Workflow
  2. In the Eclipse IDE, right-click on the root element of the dev-calculator project
  • Click Show in
  • Click System Explorer Extend Calculation Workflow
  1. Delete the folder src of the root project
  • Copy the contents of the CalculatorStepAddition project was extracted in the step 1 over to the folder we open in the step 10
  • Click Replate the file in the destination
  1. In the Eclipse IDE, right-click on the root element of the dev-calculator project
  • Click Maven
  • Click Update Project… Extend Calculation Workflow
  1. In the Eclipse IDE, right-click on the root element of the dev-calculator project
  • Click Run As
  • Click JUnit Test Extend Calculation Workflow
  1. We will receive the following result Extend Calculation Workflow
  2. Open Command Prompt, Execute the below command to navigate to the directory of dev-calculator project and to review the changed code files
cd C:\Users\Administrator\git\dev-calculator
git status

Extend Calculation Workflow 16. Execute the below command to add in the changed files

git add .
git commit -m “dev-calculator”

Extend Calculation Workflow 17. Configurethe Role for the CodeStar

  • Go to AWS IAM Console.
  • Click Roles.
  • Type CodeStarWorker-dev-calculator-CloudFormation to the search bar
  • Click CodeStarWorker-dev-calculator-CloudFormation Extend Calculation Workflow
  1. In the Permissions policies section
  • Click Add permissions
  • Click Attach Policies Extend Calculation Workflow
  1. Type idevelopCodeStarCloudFormationPolicy to the search bar
  • Select DevAx-04-idevelopCodeStarCloudFormationPolicy…
  • Click Attach policise Extend Calculation Workflow
  1. In the Eclipse IDE, right-click on the root element of the dev-calculator project
  • Click Team
  • Click Push to origin. Extend Calculation Workflow

    AWS CodePipeline will now use CloudFormation to deploy the following resources:
          - A new Step Function state machine that calls a Lambda function to perform Addition operations on the input payload.
          - The Lambda function implemented by the Java code you checked into CodeCommit.
          - IAM roles for the Lambda function and Step Function.

  1. Monitor the deployment
  • Go to AWS Step Function Console.
  • Click State machines.
  • Type CalculatorStateMachine to the search bar
  • Click state machine whose name starts by CalculatorStateMachine . Extend Calculation Workflow
  1. Click Start execution Extend Calculation Workflow
  2. In the Inpput section, type
{
  "operator" : "add",
  "operands" : [
      1,
      2
  ]
}
  • Click Start execution Extend Calculation Workflow
  1. We will receive the following result Extend Calculation Workflow