Skip to content

Moesif/moesif-aws-lambda-php-with-docker-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moesif AWS Lambda EXample for PHP with Docker

This project contains source code and supporting files for a serverless application that you can deploy with the AWS Serverless Application Model (AWS SAM) command line interface (CLI). It contains a custom runtime PHP Lambda function packaged as a docker contaier image. It deploys an Amazon HTTPs API endpoint to invoke the Lambda function.

Testing locally

  1. Clone this repo and edit the runtime/bootstrap file to set your actual Moesif Application Id.

    Your Moesif Application Id can be found in the Moesif Portal. After signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps.

    You can always find your Moesif Application Id at any time by logging into the Moesif Portal, click on the top right menu, and then clicking API Keys.

  2. Build the previous custom runtime image using the Docker build command:

docker build -t phpmyfunction .
  1. Run the function locally using the Docker run command, bound to port 9000:
docker run -d -p 9000:8080 phpmyfunction:latest
  1. This command starts up a local endpoint at localhost:9000/2015-03-31/functions/function/invocations

  2. Post an event to this endpoint using a curl command. The Lambda function payload is provided by using the -d flag. This is a valid Json object required by the Runtime Interface Emulator:

curl "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"queryStringParameters": {"name":"Ben"}}'

Congratulations! If everything was done correctly, Moesif should now be tracking all network requests. If you have any issues with set up, please reach out to support@moesif.com.

Limitations

Currently, Amazon AWS doesn't have support for PHP Lambda function, and due to the limitation of Runtime API, we can’t capture the request - uri, verb, headers, ip address etc. So have hardcoded few details to capture and send events to Moesif. Once AWS adds the support, we'll capture more details and update the example.

Other integrations

To view more documentation on integration options, please visit the Integration Options Documentation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published