<commit_before># Zombie Microservices Workshop: Lab Guide

## All Labs must be performed in us-west-2 (Oregon)

## Overview
This workshop has several lab exercises that you can complete to extend the functionality of the base chat app that is provided when you launch the CloudFormation template provided. Each of these labs is an independent section and you may choose to do some or all of them.
*   **Typing Indicator**  
    This exercise already has the UI and backend implemented, and focuses on how to setup the API Gateway to provide a RESTful endpoint.
*   **SMS Integration with Twilio**  
    This exercise wires together Twilio to an existing API Gateway stack. It shows how you can leverage templates in API Gateway to transform form posted data into JSON format for the backend lambda function.
*   **Search over the chat messages**  
    This exercise adds an Elasticsearch cluster, which is used to index chat messages streamed from a DynamoDB table.
*   **Slack Integration**  
    This exercise integrates Slack into the chat application to send messages from Slack.
*   **Intel Edison Zombie Motion Sensor**  
    This exercise integrates motion sensor detection of zombies to the chat system using an Intel Edison board and a Grove PIR Motion Sensor.
*   **Workshop Cleanup**  
    This section points out some instructions to tear down your environment when you're done working on the labs. 

* * *

### Let's Begin! Launch the CloudFormation Stack
1\. To begin this workshop, click the 'Deploy to AWS' button below. 

[![Launch Zombie Workshop Stack into Oregon with CloudFormation](/Images/deploy-to-aws.png)](https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/new?stackName=ZombieWorkshopStack&templateURL=https://s3-us-west-2.amazonaws.com/reinvent-wrk305-2015/CreateZombieWorkshop.json)

2\. On the "Specify Details" page, your Stack is prepopulated with the name "ZombieWorkshopStack".

3\. For the parameter section, if you want to develop with a team and would like to create IAM Users in your account to grant them access, then specify how many teammates/users you want to be created in the **NumberOfIAMUsers** box. Otherwise, leave it defaulted to 0 and no additional users will be created. Click **Next**.

4\. On the "Options" page, leave the defaults and click **Next**.

5\. On the "Review" page, verify your selections, then scroll to the bottom and acknowledge that your Stack will launch IAM resources for you. Then click **Create** to launch your stack. 

6\. Your stack will take about 3 minutes to launch and you can track its progress in the "Events" tab. When it is done creating, the status will change to "CREATE_COMPLETE".

7\. Click the "Outputs" tab and click the link for "MyChatRoomURL". This should open your chat application in a new tab. 

8\. In your chat application, type your name (or a fun username!) in the "User Name" field, then begin typing messages in the textbox at the bottom of the screen where it displays "Enter a message and save humanity".

9\. Your messages should begin showing up in the central chat pane window. Feel free to share the URL with your teammates, have them login and begin chatting as a group! If building this solution solo, you can logout and log back in with a different User Name to simulate multiple users.

**The baseline chat application is now configured and working! There is still important functionality missing and the Lambda Signal Corps needs you to build it out...so get started below!**

## Lab 1 - Typing Indicator

The typing indicator shows up in the web chat client. It's a section above the post message input that shows when other survivors are typing. The UI and backend Lambda functions have been implemented, and this lab focuses on how to enable the feature in API Gateway.

The application uses [CORS](http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html). This lab will both wire up the backend Lambda function as well as perform the necessary steps to enable CORS.

**Typing Indicator Architecture**
![Overview of Typing Indicator Architecture](/Images/TypingIndicatorOverview.png)

1\. Select the API Gateway Service from the main console page 
![API Gateway in Management Console](/Images/Typing-Step1.png) 

2\. Select the Zombie Workshop API Gateway 

3\. Go into the /zombie/talkers/GET method flow 
![GET Method](/Images/Typing-Step3.png) 

4\. Select the Integration Request component in the flow 

5\. Under Integration Type, Select Lambda Function 

6\. Select the us-west-2 region 

7\. Select the **_[CloudformationTemplateName]_**-GetTalkersFromDynamoDB-**_[XXXXXXXXXX]_** Function 

8\. Select Save and Grant access for API Gateway to invoke the Lambda function. 

9\. Click the Method Response section of the Method Execution Flow 

10\. Add a 200 HTTP Status response 
![Method Response](/Images/Typing-Step10.png) 

11\. Go to the /zombie/talkers/POST method 
![POST Method](/Images/Typing-Step11.png) 

12\. Perform Steps 4-10, but instead select the **_[CloudformationTemplateName]_**-WriteTalkersToDynamoDB-**_[XXXXXXXXXX]_** Lambda Function 

13\. Go to the /zombie/talkers/OPTIONS method 

14\. Select the Method Response 

15\. Add a 200 method response 

16\. Go back to the OPTIONS method flow and select the Integration Response 

17\. Select the Integration Response 

18\. Add a new Integration response with a method response status of 200 (leaving the regex blank) 

19\. Select the /zombie/talkers resource on the left navigation tree.
![talker resource](/Images/Typing-Step19.png) 

20\. Select "Enable CORS" in the top right of the screen. If there is no "Enable CORS" button, click the "Actions" button then select "Enable CORS" in the dropdown.

21\. Select Enable and Yes to replace the existing values 
![talker resource](/Images/Typing-Step21.png) 

22\. Select Deploy API  
![talker resource](/Images/Typing-Step22.png) 

23\. Select the ZombieWorkshopStage deployment and hit the Deploy button. The typing indicator should now show when survivors are typing.  As you type, POST requests are being made to the Talkers DynamoDB table as is continuous polling (GET Requests) on that table to see who which survivors are typing.
![talker resource](/Images/Typing-Done.png)

* * *

## Lab 2 - SMS Integration with Twilio<commit_msg>More details added to end of Lab 1<commit_after># Zombie Microservices Workshop: Lab Guide

## All Labs must be performed in us-west-2 (Oregon)

## Overview
This workshop has several lab exercises that you can complete to extend the functionality of the base chat app that is provided when you launch the CloudFormation template provided. Each of these labs is an independent section and you may choose to do some or all of them.
*   **Typing Indicator**  
    This exercise already has the UI and backend implemented, and focuses on how to setup the API Gateway to provide a RESTful endpoint.
*   **SMS Integration with Twilio**  
    This exercise wires together Twilio to an existing API Gateway stack. It shows how you can leverage templates in API Gateway to transform form posted data into JSON format for the backend lambda function.
*   **Search over the chat messages**  
    This exercise adds an Elasticsearch cluster, which is used to index chat messages streamed from a DynamoDB table.
*   **Slack Integration**  
    This exercise integrates Slack into the chat application to send messages from Slack.
*   **Intel Edison Zombie Motion Sensor**  
    This exercise integrates motion sensor detection of zombies to the chat system using an Intel Edison board and a Grove PIR Motion Sensor.
*   **Workshop Cleanup**  
    This section points out some instructions to tear down your environment when you're done working on the labs. 

* * *

### Let's Begin! Launch the CloudFormation Stack
1\. To begin this workshop, click the 'Deploy to AWS' button below. 

[![Launch Zombie Workshop Stack into Oregon with CloudFormation](/Images/deploy-to-aws.png)](https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/new?stackName=ZombieWorkshopStack&templateURL=https://s3-us-west-2.amazonaws.com/reinvent-wrk305-2015/CreateZombieWorkshop.json)

2\. On the "Specify Details" page, your Stack is prepopulated with the name "ZombieWorkshopStack".

3\. For the parameter section, if you want to develop with a team and would like to create IAM Users in your account to grant them access, then specify how many teammates/users you want to be created in the **NumberOfIAMUsers** box. Otherwise, leave it defaulted to 0 and no additional users will be created. Click **Next**.

4\. On the "Options" page, leave the defaults and click **Next**.

5\. On the "Review" page, verify your selections, then scroll to the bottom and acknowledge that your Stack will launch IAM resources for you. Then click **Create** to launch your stack. 

6\. Your stack will take about 3 minutes to launch and you can track its progress in the "Events" tab. When it is done creating, the status will change to "CREATE_COMPLETE".

7\. Click the "Outputs" tab and click the link for "MyChatRoomURL". This should open your chat application in a new tab. 

8\. In your chat application, type your name (or a fun username!) in the "User Name" field, then begin typing messages in the textbox at the bottom of the screen where it displays "Enter a message and save humanity".

9\. Your messages should begin showing up in the central chat pane window. Feel free to share the URL with your teammates, have them login and begin chatting as a group! If building this solution solo, you can logout and log back in with a different User Name to simulate multiple users.

**The baseline chat application is now configured and working! There is still important functionality missing and the Lambda Signal Corps needs you to build it out...so get started below!**

## Lab 1 - Typing Indicator

The typing indicator shows up in the web chat client. It's a section above the post message input that shows when other survivors are typing. The UI and backend Lambda functions have been implemented, and this lab focuses on how to enable the feature in API Gateway.

The application uses [CORS](http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html). This lab will both wire up the backend Lambda function as well as perform the necessary steps to enable CORS.

**Typing Indicator Architecture**
![Overview of Typing Indicator Architecture](/Images/TypingIndicatorOverview.png)

1\. Select the API Gateway Service from the main console page 
![API Gateway in Management Console](/Images/Typing-Step1.png) 

2\. Select the Zombie Workshop API Gateway 

3\. Go into the /zombie/talkers/GET method flow 
![GET Method](/Images/Typing-Step3.png) 

4\. Select the Integration Request component in the flow 

5\. Under Integration Type, Select Lambda Function 

6\. Select the us-west-2 region 

7\. Select the **_[CloudformationTemplateName]_**-GetTalkersFromDynamoDB-**_[XXXXXXXXXX]_** Function 

8\. Select Save and Grant access for API Gateway to invoke the Lambda function. 

9\. Click the Method Response section of the Method Execution Flow 

10\. Add a 200 HTTP Status response 
![Method Response](/Images/Typing-Step10.png) 

11\. Go to the /zombie/talkers/POST method 
![POST Method](/Images/Typing-Step11.png) 

12\. Perform Steps 4-10, but instead select the **_[CloudformationTemplateName]_**-WriteTalkersToDynamoDB-**_[XXXXXXXXXX]_** Lambda Function 

13\. Go to the /zombie/talkers/OPTIONS method 

14\. Select the Method Response 

15\. Add a 200 method response 

16\. Go back to the OPTIONS method flow and select the Integration Response 

17\. Select the Integration Response 

18\. Add a new Integration response with a method response status of 200 (leaving the regex blank) 

19\. Select the /zombie/talkers resource on the left navigation tree.
![talker resource](/Images/Typing-Step19.png) 

20\. Select "Enable CORS" in the top right of the screen. If there is no "Enable CORS" button, click the "Actions" button then select "Enable CORS" in the dropdown.

21\. Select Enable and Yes to replace the existing values 
![talker resource](/Images/Typing-Step21.png) 

22\. Select Deploy API  
![talker resource](/Images/Typing-Step22.png) 

23\. Select the ZombieWorkshopStage deployment and hit the Deploy button. The typing indicator should now show when survivors are typing.  
![talker resource](/Images/Typing-Done.png)

As you type, POST requests are being made to the Talkers DynamoDB table as is continuous polling (GET Requests) on that table to see who which survivors are typing.

* * *

## Lab 2 - SMS Integration with Twilio
{'fraction_non_alphanumeric': 0.06848556741795175, 'fraction_numerical': 0.01383946223803875, 'mean_word_length': 4.140650406504065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3151790', 'n_tokens_mistral': 3561, 'n_tokens_neox': 3247, 'n_words': 1774}