Remove hard-coded user names from Lambda

  1. Go to Chat-Conversation-GET lambda function
  • Find: {S: 'Student'}
  • Change it: {S: event.cognitoUsername}
  • Choose Deploy
  • Choose configure test
  1. At configure test event
  • Edit saved event
  • Event JSON
{
    "cognitoUsername": "Student"
}
  • Choose Save
  1. Check the results
  2. Go to Chat-Conversation-POST lambda function
  • Find: {S: 'Student'}
  • Change it: {S: event.cognitoUsername}
  • Choose Deploy
  1. At API gateway
  • Choose GET in /conversations
  • Choose Integration request
  • Choose Edit
  1. Mapping templates
  • Content type: application/json
  • Template body:
{
    "cognitoUsername": "Student"
}

  • Choose Save
  1. At API gateway
  • Choose POST in /{id}
  • Choose Integration request
  • Choose Edit
  1. Mapping templates
  • Content type: application/json
  • Template body:
{
    echo "code"
    "cognitoUsername": "Student"
}

9. At API Interface

  • Choose Deploy API
  • Stage: prod
  • Choose Deploy
  1. At stages
  • Choose stage actions
  • Choose generate SDK
  • Platform: Javascript
  • Choose Generate SDK
  1. At S3 Bucket
  • Choose Upload
  • Choose Add files
  1. Extract file zip of sdk file
  • Choose and drop this folder into ../js/
  • Grant public-read access
  • Choose I understand
  • Choose Upload
  1. Test again with browser chat-app remove harded-code