Skip to content

Instantly share code, notes, and snippets.

View mwkorver's full-sized avatar

Mark Korver mwkorver

View GitHub Profile
#cloud-boothook
#!/bin/bash
set -x
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
# fix for "unable to resolve host" error even when dns hostnames/resolution are turned on for VPC
echo "127.0.0.1 $(hostname)" >> /etc/hosts
# copy shapefiles from S3 bucket
@mwkorver
mwkorver / leaflet_example.html
Last active March 12, 2016 01:30
Workshop leaflet example HTML
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Tile-maker Demo using NAIP on S3</title>
<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
<script src="http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
@mwkorver
mwkorver / s3redirect
Last active March 25, 2016 20:57
S3 redirect for TMS
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>403</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>maptilerworkshop.elasticbeanstalk.com</HostName>
<ReplaceKeyPrefixWith>?tile=</ReplaceKeyPrefixWith>
<HttpRedirectCode>303</HttpRedirectCode>
</Redirect>
@mwkorver
mwkorver / mapserver.user-data
Last active August 24, 2016 14:36
EC2 user data script to deploy MapServer container mounting USDA NAIP data (about 100TB) in aws-naip bucket.
#cloud-boothook
#!/bin/bash
set -x
# This EC2 user-data file will run a Mapserver docker container.
# Still working on getting it to reboot properly. See this link for more info on user-data scripts
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-shell-scripts
# Because this setup uses data stored in an S3 bucket located in the standard region, it needs to be run in us-east-1 (Virginia Region).
# It mounts S3 data by using danilop/yas3fs. USDA CONUS NAIP data, Mapfile and shapefile indexes are made available to Mapserver in this way.
# Just running this instance will give you access to all of the NAIP data via the EC2 instance's filesystem.
# One caveat is that the combination of mapfile and UTM projected geotifs only supports WMS requests near native 1m/pixel resolution or level 17,