MaxMind provides IP intelligence through the GeoIP brand. Over 5,000 companies use GeoIP data to locate their Internet visitors, show them relevant content and ads, perform analytics, enforce digital rights, and efficiently route Internet traffic. GeoIP2 IP intelligence products and services can provide data on geolocation, network information, anonymizer status and offer three types of data
- Binary Database
- CSV Database
- WebService
This repository is how to use the Binary Database in a serverless context using the crates maxminddb
- Create an AWS account if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
- AWS CLI installed and configured
- Git Installed
- AWS Serverless Application Model (AWS SAM) installed
- Rust 1.56.0 or higher
- cargo-zigbuild and Zig for cross-compilation
- Working with HTTP APIs
- Working with AWS Lambda proxy integrations for HTTP APIs
- AWS Lambda - the Basics
- Lambda Function Handler
- Function Event Object - Overview
- Function Event Object - HTTP API v2 Event
- Function Context Object - Overview
- Function Context Object in Node.js - Properties
- Function Environment Variables
The SAM template deploys an Amazon API Gateway HTTP API and an AWS Lambda function.
-
Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:
git clone https://github.com/ymwjbxxq/rust_geoip
-
Change directory to the pattern directory:
cd rust_geoip
-
Install dependencies and build:
make build
-
From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
make deploy
-
During the prompts:
- Enter a stack name
- Enter the desired AWS Region
- Allow SAM CLI to create IAM roles with the required permissions.
Once you have run
sam deploy -guided
mode once and saved arguments to a configuration file (samconfig.toml), you can usesam deploy
in future to use these defaults. -
Note the outputs from the SAM deployment process. These contain the resource names and ARNs which are used for testing.
Binary files are not provided
Once the application is deployed, retrieve the HttpApiEndpoint value from CloudFormation Outputs. Then, either browse to the endpoint in a web browser or call the endpoint from Postman.
Example GET Request: https://{HttpApiId}.execute-api.{region}.amazonaws.com/countrycode
Response:
{
"countrycode": "IT"
}
- Delete the stack
make delete