Recently, I really wanted to find a way to build an API that would take in a URL and save a screenshot.

My initial use case was simple: if I was analyzing phishing emails, I wanted an easy way to get a screenshot of the URL that the email was trying to direct their targets to.

To build this, I used Terraform to create all of the infrastructure necessary to set it up in AWS, using Selenium, chromedriver, and headless Chrome to obtain the screenshots.

High level diagram illustrating what will be built in AWSHigh level diagram illustrating what will be built in AWS by Terraform

Note: All code samples are from PowerShell, so please excuse the “.” notation.

Requirements

  • An AWS account
  • Terraform binary
  • Existing S3 bucket to store Terraform state (https://www.terraform.io/docs/backends/types/s3.html)
  • AWS IAM user and access key created with appropriate permissions (programmatic access, administrative group) for Terraform usage

How to Set Up the Project

Create your new directory and initialize Terraform like this:

mkdir .\screenshot-service
cd .\screenshot-service
.\terraform init

#terraform #aws #api #developer

How to Build a Screenshot Capture API Using Terraform, AWS API Gateway, and AWS Lambda
2.45 GEEK