If you have gone through Module 2: Secrets
If you have gone through [**Module 2: Secrets**](../02-add-secrets-manager), you would have added the AWS SDK to `dbUtils.js` so the code would retrieve the database username and password from [**AWS Secrets Manager**](https://aws.amazon.com/secrets-manager/)
1. Install the XRay SDK in the `app/` folder by running in a terminal
```bash
cd ~/environment/aws-serverless-security-workshop/src/app
npm install aws-xray-sdk-core --save
```
1. In `app/dbUtils.js`, find the line where the AWS SDK is imported:
```javascript
const AWS = require('aws-sdk');
```
And replace it with:
```javascript
const AWSXRay = require('aws-xray-sdk-core');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
```
## Module 8C: Deploy lambda changes and test
1. In the terminal, validate the SAM template:
```
cd ~/environment/aws-serverless-security-workshop/src/
sam validate -t template.yaml
```
1. Deploy the updates:
```
aws cloudformation package --output-template-file packaged.yaml --template-file template.yaml --s3-bucket $BUCKET --s3-prefix securityworkshop --region $REGION && aws cloudformation deploy --template-file packaged.yaml --stack-name CustomizeUnicorns --region $REGION --parameter-overrides InitResourceStack=Secure-Serverless --capabilities CAPABILITY_IAM
```
1. Once the deployment finishes, test making API requests again with postman.
1. Go to the [**X-Ray console**](https://console.aws.amazon.com/xray/home), go to the **Service map** tab and refresh. You should start seeing some lambda requests getting captured!
## Module 8D: Enable X-Ray on API Gateway
1. Go to [API Gateway Console](https://console.aws.amazon.com/apigateway/home), and go to the `CustomizeUnicorns` API
1. Go to the **Stages** tab, click on the `dev` stage
1. Find the **Logs/Tracing** tab, check the box for **Enable X-Ray Tracing**, and **Save changes**

1. Redeploy the API by clicking on the **Resources** tab on the left hand side --> **Actions** --> **Deploy API** -> Pick the `dev` stage --> **deploy**.
1. Test making a few making API requests with postman.
1. Go to the [**X-Ray console**](https://console.aws.amazon.com/xray/home), go to the **Service map** tab and refresh

1. Explore the service map. Click on various components, and use **View traces** to see a list of request traces captured by X-Ray

1. Explore the individual traces by clicking into individual requests

## Next Step
Return to the workshop [landing page](../../README.md) to pick another module.