All Projects → luisfarzati → Chromda

luisfarzati / Chromda

Licence: mit
λ 🖼️ Chromda is an AWS Lambda function for capturing screenshots of websites.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Chromda

Chrome Aws Lambda
Chromium Binary for AWS Lambda and Google Cloud Functions
Stars: ✭ 2,502 (+420.17%)
Mutual labels:  aws, serverless, aws-lambda, puppeteer
Chart To Aws
Microservice to generate screenshot from a webpage and upload it to a AWS S3 Bucket.
Stars: ✭ 43 (-91.06%)
Mutual labels:  aws, screenshot, puppeteer, chrome-headless
Serverless Rust
⚡ 🦀 a serverless framework plugin for rustlang applications
Stars: ✭ 386 (-19.75%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Architecture Boilerplate
📦 ⚡️ 🚀 Boilerplate to organize and deploy big projects using AWS API Gateway and AWS Lambda with Serverless Framework
Stars: ✭ 269 (-44.07%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Plugin Canary Deployments
Canary deployments for your Serverless application
Stars: ✭ 283 (-41.16%)
Mutual labels:  aws, serverless, aws-lambda
Serverlessbydesign
A visual approach to serverless development. Think. Build. Repeat.
Stars: ✭ 254 (-47.19%)
Mutual labels:  aws, serverless, aws-lambda
Laconia
Create well-crafted serverless applications, effortlessly
Stars: ✭ 260 (-45.95%)
Mutual labels:  aws, serverless, aws-lambda
Aws Auto Cleanup
Open-source application to programmatically clean your AWS resources based on a whitelist and time to live (TTL) settings
Stars: ✭ 276 (-42.62%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Chrome
🌐 Run headless Chrome/Chromium on AWS Lambda
Stars: ✭ 2,625 (+445.74%)
Mutual labels:  aws, serverless, aws-lambda
Grant
OAuth Proxy
Stars: ✭ 3,509 (+629.52%)
Mutual labels:  aws, serverless, aws-lambda
Cljs Lambda
Utilities around deploying Clojurescript functions to AWS Lambda
Stars: ✭ 304 (-36.8%)
Mutual labels:  aws, serverless, aws-lambda
Express
⚡ Take existing Express.js apps and host them easily on cheap, auto-scaling, serverless infrastructure (AWS Lambda and AWS HTTP API).
Stars: ✭ 337 (-29.94%)
Mutual labels:  aws, serverless, aws-lambda
screenie-server
A Node server with a pool of Puppeteer (Chrome headless) instances for scalable screenshot generation.
Stars: ✭ 19 (-96.05%)
Mutual labels:  screenshot, chrome-headless, puppeteer
Aws Lambda Typescript
This sample uses the Serverless Application Framework to implement an AWS Lambda function in TypeScript, deploy it via CloudFormation, publish it through API Gateway to a custom domain registered on Route53, and document it with Swagger.
Stars: ✭ 228 (-52.6%)
Mutual labels:  aws, serverless, aws-lambda
Aws To Slack
Forward AWS CloudWatch Alarms and other notifications from Amazon SNS to Slack.
Stars: ✭ 261 (-45.74%)
Mutual labels:  aws, serverless, aws-lambda
Algnhsa
AWS Lambda Go net/http server adapter
Stars: ✭ 226 (-53.01%)
Mutual labels:  aws, serverless, aws-lambda
Aws Serverless Samfarm
This repo is full CI/CD Serverless example which was used in the What's New with AWS Lambda presentation at Re:Invent 2016.
Stars: ✭ 271 (-43.66%)
Mutual labels:  aws, serverless, aws-lambda
Claudia
Deploy Node.js projects to AWS Lambda and API Gateway easily
Stars: ✭ 3,690 (+667.15%)
Mutual labels:  aws, serverless, aws-lambda
Retinal
🏙 Retinal is a Serverless AWS Lambda service for resizing images on-demand or event-triggered
Stars: ✭ 208 (-56.76%)
Mutual labels:  aws, serverless, aws-lambda
Aws Lambda Haskell Runtime
⚡Haskell runtime for AWS Lambda
Stars: ✭ 223 (-53.64%)
Mutual labels:  aws, serverless, aws-lambda

Chromda – Serverless screenshots

Chromda is an AWS Lambda function for serverless capturing screenshots of websites.

Multiple sources

  • SNS topics
  • SQS queues
  • CloudWatch scheduled events
  • API Gateway proxy

Configurable

  • Capture full page, viewport or specific DOM element
  • Exclude DOM elements (useful for ads or other unwanted content)
  • Override styles

Quick start

Provided you already have AWS credentials for Serverless, do:

git clone https://github.com/luisfarzati/chromda
cd chromda
git submodule update --init
npm install

Edit the serverless.yml file and change the example bucket name with one of your own:

# serverless.yml
custom:
  s3Bucket: <your bucket name>

Deploy the function into your AWS account:

npm run deploy

Open the AWS Lambda Console and create the following test event:

{
  "source": "aws.events",
  "time": "1970-01-01T00:00:00Z",
  "detail": {
    "url": "https://www.nytimes.com"
  }
}

Click Test, wait a few seconds (it might take around 8-10 secs), then you should see a response like:

{
  "url": "https://<your bucket name>.s3.amazonaws.com/<uuid>.png"
}

Usage

Invocation

The function accepts different kind of events, extracting the data from the proper body attribute as follows:

Event Body is extracted from
SNS Message Event .Records[0].Sns.Message
SQS Message Event .Records[0].body
API Gateway Message Event .body
CloudWatch Events Message Event .detail

Options

{
  // required
  "url": "https://google.com",

  // optional - valid options: page, viewport, element
  // default: viewport
  "capture": "page",

  // selector of element to capture
  // required if capture: element
  "selector": ".container",

  // optional - S3 key for the image file
  // default: uuid()
  "s3key": "test.png",

  // optional - selectors of elements to exclude
  "exclude": [".ad", "video"],

  // optional - styles to override
  // see Puppeteer.addStyleTag
  "styles": [
    {
      "content": "body { color: #f00; }"
    }
  ],

  // optional - puppeteer options
  "puppeteer": {
    // see Puppeteer.goto options
    "navigation": {
      "timeout": 30000,
      "waitUntil": ["domcontentloaded", "networkidle2"]
    },
    // see Puppeteer.screenshot options
    "screenshot": {
      "type": "jpeg",
      "quality": 50,
      "omitBackground": false
    },
    // viewport size, overrides env defaults
    "viewport": {
      "width": 1200,
      "height": 2000
    }
  }
}

Environment Variables

Name Default
S3_BUCKET*
S3_REGION*
S3_ACL "public-read"
CHROMIUM_ARGS "[]"
TIMEOUT "30000"
IGNORE_HTTPS_ERRORS "false"
VIEWPORT_WIDTH "1920"
VIEWPORT_HEIGHT "1200"
DEVICE_SCALE_FACTOR "1"
IS_MOBILE "false"
IS_LANDSCAPE "false"

Deploy

# serverless.yml

# ...
custom:
  s3Bucket: <your bucket name>

provider:
  # ...
  layers:
    # Replace <version> with the latest version of chrome-aws-lambda-layer
    # It depends on the region you are deploying.
    # https://github.com/shelfio/chrome-aws-lambda-layer#available-regions
    - arn:aws:lambda:${self:provider.region}:764866452798:layer:chrome-aws-lambda:<version>

functions:
  captureScreenshot:
    # ...
    environment:
      # configure the environment variables
      VIEWPORT_WIDTH: "1920"
      VIEWPORT_HEIGHT: "1200"
      # ...
    events:
      # add any of the supported event source(s) you want to use
      # the provided example uses SNS
      - sns:
          arn: !Ref chromdaTopic
          topicName: ${self:custom.snsTopic}

resources:
  # following the example, we provision an SNS topic
  chromdaTopic:
    Type: AWS::SNS::Topic
    Properties:
      TopicName: ${self:custom.snsTopic}

X-Ray

AWS X-Ray support is provided and there are segments for Puppeteer navigation and screenshot:

AWS X-Ray screenshot

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].