Skip to content

This serverless application provides a phone home endpoint for recording contacts from another deployed application.

License

Notifications You must be signed in to change notification settings

evanchiu/phone-home

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phone-home

This serverless application provides a phone home endpoint for recording contacts from another deployed application.

It provides a demo integration of API Gateway + AWS Lambda + Node.js + Amazon DynamoDB

Deploy with CloudFormation

Prerequisites: Node.js and AWS CLI installed

  • Create an AWS Account and IAM User with the AdministratorAccess AWS Managed Policy
  • Run aws configure to put store that user's credentials in ~/.aws/credentials
  • Create an S3 bucket for storing the Lambda code and store its name in a shell variable with:
    • export CODE_BUCKET=<bucket name>
  • Npm install:
    • npm install
  • Build:
    • npm run build
  • Upload package to S3, transform the CloudFormation template:
    • npm run package
  • Deploy to CloudFormation:
    • npm run deploy

Deploy from the AWS Serverless Application Repository

Usage

Find Invocation URL

Command line

Post data:

curl -d '{"username":"you", "host":"localhost"}' https://xxxxxxxxx.execute-api.region.amazonaws.com/Prod/

Get data:

curl https://xxxxxxxxx.execute-api.region.amazonaws.com/

JavaScript

Post data for logged in user (Take care to comply with any applicable Do Not Track legislation):

// Phone home if we're not on localhost
function phoneHome(username) {
  if (!window.location.host.includes('localhost')) {
    fetch('https://xxxxxxxxx.execute-api.region.amazonaws.com/',
      {
        method: 'POST',
        body: JSON.stringify({
          username: username,
          host: window.location.host
        })
      });
  }
}

Links

License

© 2017-2019 Evan Chiu. This project is available under the terms of the MIT license.

About

This serverless application provides a phone home endpoint for recording contacts from another deployed application.

Resources

License

Stars

Watchers

Forks

Packages

No packages published