Serverless Histogram Generator using AWS Lambda and Go.
Create a deployment package by packaging the executable in a ZIP file, and use the AWS CLI to create a function. Please read AWS Lambda deployment package in Go for more information.
go get github.com/aws/aws-lambda-go/lambda
GOOS=linux go build -o main main.go
zip function.zip main
aws lambda create-function --function-name my-function --runtime go1.x --zip-file fileb://function.zip --handler main --role arn:aws:iam::123456789012:role/execution_role
Make a post request with json data:
{"values": [1, 18, 2, 5, 10, 1, 2, 3]}
And you will get a response with an SVG:
<?xml version="1.0"?>
<!-- Generated by SVGo -->
<svg width="40" height="18"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="0" y="17" width="5" height="1" fill="#CBD5E0" onmouseover="evt.target.setAttribute('fill', '#A9AED9');" onmouseout="evt.target.setAttribute('fill', '#CBD5E0');" />
<rect x="5" y="0" width="5" height="18" fill="#CBD5E0" onmouseover="evt.target.setAttribute('fill', '#A9AED9');" onmouseout="evt.target.setAttribute('fill', '#CBD5E0');" />
<rect x="10" y="16" width="5" height="2" fill="#CBD5E0" onmouseover="evt.target.setAttribute('fill', '#A9AED9');" onmouseout="evt.target.setAttribute('fill', '#CBD5E0');" />
<rect x="15" y="13" width="5" height="5" fill="#CBD5E0" onmouseover="evt.target.setAttribute('fill', '#A9AED9');" onmouseout="evt.target.setAttribute('fill', '#CBD5E0');" />
<rect x="20" y="8" width="5" height="10" fill="#CBD5E0" onmouseover="evt.target.setAttribute('fill', '#A9AED9');" onmouseout="evt.target.setAttribute('fill', '#CBD5E0');" />
<rect x="25" y="17" width="5" height="1" fill="#CBD5E0" onmouseover="evt.target.setAttribute('fill', '#A9AED9');" onmouseout="evt.target.setAttribute('fill', '#CBD5E0');" />
<rect x="30" y="16" width="5" height="2" fill="#CBD5E0" onmouseover="evt.target.setAttribute('fill', '#A9AED9');" onmouseout="evt.target.setAttribute('fill', '#CBD5E0');" />
<rect x="35" y="15" width="5" height="3" fill="#CBD5E0" onmouseover="evt.target.setAttribute('fill', '#A9AED9');" onmouseout="evt.target.setAttribute('fill', '#CBD5E0');" />
</svg>