# What is this app?

This app is a lambda function that runs the Topology JWT handoff lookup described in this doc: https://topologyeyewear.notion.site/JWT-patient-handoff-a0108301e7b64bb6b21ab5b5a446fdd2

When a browser requests https://scan.bigscreencloud.com we redirect to the correct network depending on what database the topology patient id is contained in.

THIS APPLICATION WAS BUILT DIFFERENT.  The lambda function is unique in that it doesn't exist in a single network, but rather has readonly access to all the dynamo DB tables that contain the Topology lookup information.



# Prereqs

On windows, 7zip must be installed and accessible via the command line.

The AWS command line interface must be installed.

The local credentials file for the AWS CLI must include the "LambdaAdmin" profile.

# Lambda function for the "scan" microsite

1. Create a role

```
aws iam 

```
aws iam create-role --role-name lambda-ex --assume-role-policy-document file://IAM/trust-policy.json --profile LambdaAdmin
```

If this fails, the role is setup.

2. Check if the aws cli is setup

```
aws lambda list-functions --max-items 10 --profile LambdaAdmin
```

3. Zip up the files

On windows
```
7z.exe a function.zip index.js package.json
```

4. Create the function
```
aws lambda create-function --function-name scan-handler-v1 --zip-file fileb://scan-lambda.zip --handler index.handler --runtime nodejs16.x --role arn:aws:iam::164780942622:role/lambda-ex --profile LambdaAdmin
aws lambda update-function-configuration --function-name scan-handler-v1 --timeout 30 --profile LambdaAdmin
```

Or update it:
```
aws lambda update-function-code --function-name scan-handler-v1 --zip-file fileb://function.zip --profile LambdaAdmin
```


5. Test it
```

```

6. Get info
```
aws lambda get-function --function-name my-function --profile LambdaAdmin
```