AWS Lambda REST API to calculate distances between postcodes using Ordnance Survey Code-Point Open data
aws cloudformation deploy \
--template codepoint-distance-network.json \
--stack-name codepoint-distance-networkaws cloudformation package \
--template-file codepoint-distance-lambda.json \
--s3-bucket <BUCKET ID> \
--output-template-file codepoint-distance-lambda-output.jsonaws cloudformation deploy \
--template-file codepoint-distance-lambda-output.json \
--stack-name codepoint-distance \
--capabilities CAPABILITY_IAMaws s3 cp codepo_gb.zip s3://<BUCKET ID>aws lambda invoke \
--function-name CodePointLoad \
--payload '{"bucket": "<BUCKET ID>", "key": "codepo_gb.zip"}' \
response.jsonaws cloudformation describe-stacks \
--stack-name codepoint-distance \
--query 'Stacks[0].Outputs[?OutputKey==`ApiUrl`].OutputValue'curl -s https://<SERVER ID>.execute-api.eu-west-2.amazonaws.com/Prod/codepoint/distance/<POSTCODE>/<POSTCODE> | json_ppcurl -s https://77waizvyq3.execute-api.eu-west-2.amazonaws.com/Prod/codepoint/distance/YO241AB/YO17HH | json_pp
{
"distance" : 817.743235985477,
"toCodePoint" : {
"postcode" : "YO1 7HH",
"eastings" : 460350,
"northings" : 452085
},
"fromCodePoint" : {
"northings" : 451737,
"postcode" : "YO24 1AB",
"eastings" : 459610
}
}aws cloudformation delete-stack \
--stack-name codepoint-distanceaws cloudformation delete-stack \
--stack-name codepoint-distance-network