Skip to content

Terraform implenetation of Mercury Parser API on AWS using API Gateway and Lambda

Notifications You must be signed in to change notification settings

msharma24/terraform-serverless-mercury-parser-api

Repository files navigation

terraform-serverless-mercury-parser-api

Description

This project implements the Mercury Parser API with AWS API Gateway and Lambda Function using Terraform.

Mercury takes any web article and returns only the relevant content — headline, author, body text, relevant images and more

Diagram

Build and Deploy

  1. Git clone the mercury-parser-api git clone [email protected]:RecastLLC/mercury-parser-api.git
  2. cd mercury-parser-api
  3. Run yarn install inside the mercury-parser-api directory.
  4. run yarn build - This command will build the lambda deployment zip file in the local path ./serverless/mercury.zip
  5. Export the AWS Access keys to the environment
  6. terraform init
  7. terraform plan
  8. terraform apply [-auto-approve]

This will deploy the API Gateway REST API resources and the lambda function with the Mercury Parser API nodejs zip.

How to Test

1 - Login to AWS Account and access the API Gateway resources

2 - Make a note of the API Gateway Stage Execution URL

3- Make a note of the API Gateway Access Key

Use the lambda_requestion.html as the HTML file as the payload and run the following command

curl -X POST -H "Content-Type:application/json" \ 
-H "cache-control":"no-cache" -H "x-api-key:API_KEY_HERE" \
-d @lambda_request.html https://API_GATEWAY_EXECUTION_URL/STAGE_NAME/parse-html

Example command

curl -X POST -H "Content-Type:application/json" \
-H "cache-control":"no-cache" -H  \
"x-api-key:gHb7ARQQzv9Tl4JRrvpTU7018weheLITp8dBY6Od"  \
-d @lambda_request.html https://hbhsnscb63.execute-api.ap-southeast-2.amazonaws.com/Prod/parse-html

The result output will be Plain Text Extracted from the payload html file.

About

Terraform implenetation of Mercury Parser API on AWS using API Gateway and Lambda

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published