├── .gitignore ├── .npmignore ├── LICENSE ├── NOTICE ├── README.md ├── client └── dist │ └── assets │ ├── css │ ├── ie10-viewport-bug-workaround.css │ ├── jumbotron-narrow.css │ └── styles.css │ ├── img │ └── 375px-AWS_Logo_Web-Black.png │ └── js │ └── ie10-viewport-bug-workaround.js ├── package.json ├── restApi ├── lib │ ├── helpers.js │ ├── index.js │ ├── throttle.js │ └── updater.js ├── naip │ ├── download │ │ ├── event.json │ │ ├── handler.js │ │ ├── s-function.json │ │ └── s-templates.json │ ├── quad │ │ ├── event.json │ │ ├── handler.js │ │ ├── s-function.json │ │ └── s-templates.json │ ├── quads │ │ ├── event.json │ │ ├── handler.js │ │ ├── s-function.json │ │ └── s-templates.json │ ├── root │ │ ├── event.json │ │ ├── handler.js │ │ ├── s-function.json │ │ └── s-templates.json │ ├── scene │ │ ├── event.json │ │ ├── handler.js │ │ ├── s-function.json │ │ └── s-templates.json │ ├── states │ │ ├── event.json │ │ ├── handler.js │ │ └── s-function.json │ ├── throttle │ │ ├── event.json │ │ ├── handler.js │ │ └── s-function.json │ └── updater │ │ ├── event.json │ │ ├── handler.js │ │ └── s-function.json └── views │ ├── index.html │ ├── partials │ ├── footer.html │ ├── header.html │ └── nav.html │ ├── quad.html │ ├── quads.html │ ├── scene.html │ └── states.html ├── s-project.json ├── s-resources-cf.json └── s-templates.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 28 | node_modules 29 | 30 | #IDE 31 | **/.idea 32 | 33 | #OS 34 | .DS_Store 35 | .tmp 36 | 37 | #SERVERLESS 38 | admin.env 39 | .env 40 | 41 | #Ignore _meta folder 42 | _meta 43 | 44 | # Ignore generated products from data gen scripts 45 | scripts/sitemap.txt 46 | scripts/unique_prs.csv 47 | scripts/paths/*.csv 48 | scripts/scene_list 49 | client/dist/paths/*.csv 50 | client/dist/sitemap.txt 51 | client/dist/unique_prs.csv 52 | /scene_list 53 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | dist 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 19 | .grunt 20 | 21 | # node-waf configuration 22 | .lock-wscript 23 | 24 | # Compiled binary addons (http://nodejs.org/api/addons.html) 25 | build/Release 26 | 27 | # Dependency directory 28 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 29 | node_modules 30 | 31 | #IDE Stuff 32 | **/.idea 33 | 34 | #OS STUFF 35 | .DS_Store 36 | .tmp 37 | 38 | #SERVERLESS STUFF 39 | admin.env 40 | .env 41 | _meta -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | naip-on-aws 2 | Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NAIP on AWS viewer 2 | 3 | The NAIP on AWS viewer is a serverless, lightweight, fast, and infinitely scalable website designed to display data from the [NAIP on AWS](https://aws.amazon.com/public-data-sets/naip/) public data set. It uses [AWS Lambda](https://aws.amazon.com/lambda/), and [AWS API Gateway](https://aws.amazon.com/api-gateway/) to dynamically generate pages on the fly for hundreds of thousands of images stored on Amazon S3. It is based on work originally done in [landsat-on-aws](https://github.com/awslabs/landsat-on-aws). 4 | 5 | You can see an example of the website in action at https://f5f3hkneq5.execute-api.us-east-1.amazonaws.com/prod. 6 | 7 | 8 | ## Goals of this project 9 | 10 | - **Fast.** Pages should load quickly. 11 | - **Lightweight.** Hosting 100,000,000 pages should cost less than $100 per month. 12 | - **Indexable.** Pages of the site should be indexable by search engines. 13 | - **Linkable.** All unique pages of the site should have a [cool URI](http://www.w3.org/Provider/Style/URI.html) 14 | 15 | ### What this project is good for 16 | 17 | - Making NAIP imagery discoverable via search engines. 18 | - Demonstrating how scalable websites can be built based on structured data. 19 | - Demonstrating methods of controlling egress costs while publicly sharing data 20 | 21 | ### What this project _not_ good for 22 | 23 | - Analyzing NAIP data. 24 | 25 | ## Structure 26 | 27 | The project structure is a slightly modified version of the [serverless-starter](https://github.com/serverless/serverless-starter) project. Because we're returning HTML views instead of JSON, there is also a `restApi/views` directory which contains HTML templates that are rendered dynamically at request time, based on query inputs. 28 | 29 | The project relies on dynamically generating HTML output using Lambda functions at request time (requests handled by API Gateway). An updater can be run to check the latest files in the `aws-naip` S3 bucket and creates a small amount of underlying data files that get stored on S3. These files are requested by Lambda functions as needed, before HTML is returned. This means that we are only serving content-full (as opposed to using JavaScript to load data within the page itself) from API Gateway which makes indexing easier. This also means that outside of our small set of data files, we are not storing anything to present the hundreds of thousands of pages needed to reflect the underlying NAIP imagery. 30 | 31 | An architectural overview can be seen below (note that there is no Amazon DynamoDB instance in this prototype). 32 | 33 |  34 | 35 | ## Egress Control 36 | 37 | From the individual imagery page, metadata, TIFFs and shapefiles can be downloaded. When a request is made for this data (via the webpage or programmatically), a short-lived, signed URL is generated and returned to the requester. The code shows off three mechanisms for controlling total egress: 38 | 39 | 1) Via API Gateway, the `/d` endpoint is the only endpoint to have throttling turned on. By default, this is 1,000 requests per second with burst up to 2,000. 40 | 41 | 2) When the signed URL is requested, we also do a `headObject` request to get object size. We could store this data somewhere (Amazon ElastiCache or Amazon RDS) and use it to deny download requests based on total amount of data already transferred. 42 | 43 | 3) Via [Budgets](http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/budgets-managing-costs.html) you can set a monthly/quarterly/yearly budget for total cost of egress. When these limits are reached, a message is sent via AWS SNS which causes this code to greatly lower throttling limits. This code shows the example of a monthly setup where throttling limits are reset at beginning of month and lowered once budget is reached (code for this is in `naip/throttle/handler.js`. This topic is created manually and referenced in `restApi/naip/throttle/s-function.json`. 44 | 45 | ## To run and deploy 46 | 47 | 1. Download Node.JS from https://nodejs.org/download/ and install it. 48 | 49 | 2. Clone or download this repository and go into project folder. 50 | 51 | 3. Install [serverless](http://serverless.com/) globally with `npm install -g serverless`. 52 | 53 | 4. Install package dependencies with `npm install`. 54 | 55 | 5. Init serverless project with `sls project init` and follow prompts. 56 | 57 | 6. Run `sls client deploy` and take note of the S3 bucket URL returned (this will deploy some static assets to S3). 58 | 59 | 7. First time only, you will need to add some properties to the newly created `_meta/s-variables-common.json` file. The `baseURL` is the base URL of the website (this goes into creating the sitemap, if you don't care about that, go ahead and leave blank), `staticURL` is the URL of the S3 bucket for static assets (you'll see the bucket after you run `sls client deploy`). This should look something like below (make sure format matches below and includes https and trailing slash and keep in mind `us-east-1` just used `s3.amazonaws.com/foo`). 60 | >``` 61 | >"baseURL": "https://naiponaws.com/", 62 | >"staticURL": "https://s3.amazonaws.com/naiponaws.com-development-us-east-1/", 63 | >"apiGatewayId": "f5f3hkneq5" 64 | >``` 65 | 66 | 8. Deploy all the functions and endpoints once. From then on out, you can just deploy as you make changes to individual files. There are a number of different ways to deploy with serverless (refer to [documentation](http://docs.serverless.com/v0.5.0/docs)), but to deploy all try `sls dash deploy`, select everything and deploy. 67 | 68 | 9. Run the `naip-updater` function once to build up some required static files on S3 with `sls function run naip-updater -d`. 69 | 70 | 10. Once you've deployed everything, you should see in the console a URL to your endpoints to test out. You'll only need to make new deploys when you make changes to files. 71 | 72 | `sls client deploy` currently overwrites other files when deploying, which removes the data files created by running `naip-updater`. To work around this, you can either rerun `naip-updater` after each deploy of static assets, or you can deploy assets manually by doing something like `aws s3 cp client/dist/assets s3://naiponaws.com-dev-us-west-2/assets --recursive`. 73 | -------------------------------------------------------------------------------- /client/dist/assets/css/ie10-viewport-bug-workaround.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * IE10 viewport hack for Surface/desktop Windows 8 bug 3 | * Copyright 2014-2015 Twitter, Inc. 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | */ 6 | 7 | /* 8 | * See the Getting Started docs for more information: 9 | * http://getbootstrap.com/getting-started/#support-ie10-width 10 | */ 11 | @-ms-viewport { width: device-width; } 12 | @-o-viewport { width: device-width; } 13 | @viewport { width: device-width; } 14 | -------------------------------------------------------------------------------- /client/dist/assets/css/jumbotron-narrow.css: -------------------------------------------------------------------------------- 1 | /* Space out content a bit */ 2 | body { 3 | padding-top: 20px; 4 | padding-bottom: 20px; 5 | } 6 | 7 | /* Everything but the jumbotron gets side spacing for mobile first views */ 8 | .header, 9 | .marketing, 10 | .footer { 11 | padding-right: 15px; 12 | padding-left: 15px; 13 | } 14 | 15 | /* Custom page header */ 16 | .header { 17 | padding-bottom: 20px; 18 | border-bottom: 1px solid #e5e5e5; 19 | } 20 | /* Make the masthead heading the same height as the navigation */ 21 | .header h3 { 22 | margin-top: 0; 23 | margin-bottom: 0; 24 | line-height: 40px; 25 | } 26 | 27 | /* Custom page footer */ 28 | .footer { 29 | padding-top: 19px; 30 | color: #777; 31 | border-top: 1px solid #e5e5e5; 32 | } 33 | 34 | /* Customize container */ 35 | @media (min-width: 768px) { 36 | .container { 37 | max-width: 730px; 38 | } 39 | } 40 | .container-narrow > hr { 41 | margin: 30px 0; 42 | } 43 | 44 | /* Main marketing message and sign up button */ 45 | .jumbotron { 46 | text-align: center; 47 | border-bottom: 1px solid #e5e5e5; 48 | } 49 | .jumbotron .btn { 50 | padding: 14px 24px; 51 | font-size: 21px; 52 | } 53 | 54 | /* Supporting marketing content */ 55 | .marketing { 56 | margin: 40px 0; 57 | } 58 | .marketing p + h4 { 59 | margin-top: 28px; 60 | } 61 | 62 | /* Responsive: Portrait tablets and up */ 63 | @media screen and (min-width: 768px) { 64 | /* Remove the padding we set earlier */ 65 | .header, 66 | .marketing, 67 | .footer { 68 | padding-right: 0; 69 | padding-left: 0; 70 | } 71 | /* Space out the masthead */ 72 | .header { 73 | margin-bottom: 30px; 74 | } 75 | /* Remove the bottom border on the jumbotron for visual effect */ 76 | .jumbotron { 77 | border-bottom: 0; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /client/dist/assets/css/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 16px; 3 | line-height: 24px; 4 | color: #111111; 5 | font-family: Arial, sans-serif; 6 | } 7 | 8 | blockquote {font-size: 16px;} 9 | 10 | table {font-size: 80%;} 11 | 12 | h1, h2, h3, h4, h5, h6 { 13 | padding: 0; 14 | margin: 0; 15 | } 16 | 17 | h1, h2, h3, h4 { 18 | font-family: Arial, sans-serif; 19 | text-rendering: optimizeLegibility; 20 | padding-bottom: 4px; 21 | } 22 | 23 | h1:last-child, h2:last-child, h3:last-child, h4:last-child { 24 | padding-bottom: 0; 25 | } 26 | 27 | h1 { 28 | font-weight: normal; 29 | font-size: 28px; 30 | line-height: 1.2; 31 | } 32 | 33 | h2 { 34 | font-weight: bold; 35 | font-size: 21px; 36 | line-height: 1.3; 37 | } 38 | 39 | h3 { 40 | font-weight: bold; 41 | font-size: 17px; 42 | line-height: 1.255; 43 | } 44 | 45 | h4 { 46 | font-weight: normal; 47 | font-size: 17px; 48 | line-height: 1.255; 49 | } 50 | 51 | h5 { 52 | font-weight: bold; 53 | font-size: 13px; 54 | line-height: 19px; 55 | } 56 | 57 | h6 { 58 | font-weight: bold; 59 | text-transform: uppercase; 60 | font-size: 11px; 61 | line-height: 1.465; 62 | padding-bottom: 1px; 63 | } 64 | 65 | p { 66 | padding: 0; 67 | margin: 0 0 14px 0; 68 | } 69 | p:last-child { 70 | margin-bottom: 0; 71 | } 72 | p + p { 73 | margin-top: -4px; 74 | } 75 | 76 | b, strong { 77 | font-weight: bold; 78 | } 79 | 80 | i, em { 81 | font-style: italic; 82 | } 83 | 84 | blockquote { 85 | margin: 13px; 86 | } 87 | small { 88 | font-size: 12px; 89 | } 90 | 91 | a, a:visited, a:active, a:link { 92 | color: #0066c0; 93 | } 94 | 95 | #tb-s3objects { 96 | margin-top:-1px !important; 97 | } 98 | 99 | .breadcrumb {padding: 2px 8px;background-color: #f9f9f9; font-size: 80%;} 100 | 101 | header {padding:1.5em 0 .5em;} 102 | 103 | #aws_header_logo {max-width: 100px;} 104 | 105 | .jumbotron .btn { 106 | margin-top: 1em; 107 | } 108 | 109 | ul.landsat_nav_list, ul.scene_files { 110 | list-style-type: none; 111 | padding:0; 112 | } 113 | 114 | ul.scene_files { 115 | margin: 0 0 1em 0; 116 | } 117 | 118 | ul.scene_files li { 119 | margin: 0 0 .2em 0; 120 | } 121 | 122 | ul.landsat_nav_list { 123 | font-size: 140%; 124 | } 125 | 126 | ul.landsat_nav_list li a{ 127 | display:block; 128 | padding: .4em .6em; 129 | margin: .4em 0; 130 | background-color: #EEE; 131 | border-radius:6px; 132 | } 133 | 134 | ul.landsat_nav_list li a:hover{ 135 | background-color: #DDD; 136 | } 137 | 138 | footer {padding-bottom: 3em;} 139 | 140 | /*#wrapper { padding-left: 0; } 141 | #page-wrapper { width: 100%; padding: 5px 15px; }*/ 142 | #tb-s3objects { width: 100% !Important; } 143 | #preview {width: 100%;} -------------------------------------------------------------------------------- /client/dist/assets/img/375px-AWS_Logo_Web-Black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/naip-on-aws/35b45f9c985930adabedb159badedbacfbe329ae/client/dist/assets/img/375px-AWS_Logo_Web-Black.png -------------------------------------------------------------------------------- /client/dist/assets/js/ie10-viewport-bug-workaround.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * IE10 viewport hack for Surface/desktop Windows 8 bug 3 | * Copyright 2014-2015 Twitter, Inc. 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | */ 6 | 7 | // See the Getting Started docs for more information: 8 | // http://getbootstrap.com/getting-started/#support-ie10-width 9 | 10 | (function () { 11 | 'use strict'; 12 | 13 | if (navigator.userAgent.match(/IEMobile\/10\.0/)) { 14 | var msViewportStyle = document.createElement('style') 15 | msViewportStyle.appendChild( 16 | document.createTextNode( 17 | '@-ms-viewport{width:auto!important}' 18 | ) 19 | ) 20 | document.querySelector('head').appendChild(msViewportStyle) 21 | } 22 | 23 | })(); 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_npmOperationalInternal": { 3 | "host": "packages-13-west.internal.npmjs.com", 4 | "tmp": "tmp/serverless-starter-0.2.1.tgz_1458892667270_0.7738919164985418" 5 | }, 6 | "author": { 7 | "name": "Joe Flasher" 8 | }, 9 | "bugs": { 10 | "url": "https://github.com/awslabs/naip-on-aws/issues" 11 | }, 12 | "dependencies": { 13 | "async": "^2.0.0", 14 | "aws-sdk": "^2.4.11", 15 | "brfs": "^1.4.3", 16 | "csv-parse": "^1.1.7", 17 | "handlebars": "^4.0.5", 18 | "lodash": "^4.16.4", 19 | "serverless-client-s3": "^2.0.0", 20 | "serverless-optimizer-plugin": "^2.0.0" 21 | }, 22 | "description": "An example of using a serverless environment to provide data pages for NAIP imagery.", 23 | "devDependencies": {}, 24 | "homepage": "https://github.com/awslabs/naip-on-aws", 25 | "license": "Apache-2.0", 26 | "name": "naiponaws", 27 | "optionalDependencies": {}, 28 | "private": false, 29 | "repository": "https://github.com/awslabs/naip-on-aws", 30 | "scripts": {}, 31 | "version": "1.0.0" 32 | } 33 | -------------------------------------------------------------------------------- /restApi/lib/helpers.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Helper functions 16 | */ 17 | 18 | 'use strict'; 19 | 20 | module.exports.getStaticBucket = function () { 21 | return /^https?:\/\/.*\/(.*)\/$/.exec(process.env.STATIC_URL)[1]; 22 | }; 23 | 24 | // If we're on production (and presumably are using a naked domain, do not include stage in basePath) 25 | module.exports.getBasePath = function (stage) { 26 | return stage === 'production' ? '' : '/' + stage; 27 | }; 28 | -------------------------------------------------------------------------------- /restApi/lib/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Handler functions 16 | */ 17 | 18 | var AWS = require('aws-sdk'); 19 | var s3 = new AWS.S3(); 20 | var async = require('async'); 21 | var h = require('Handlebars'); 22 | var fs = require('fs'); 23 | var path = require('path'); 24 | var helpers = require('./helpers'); 25 | 26 | // NAIP - Serves landing page 27 | module.exports.naipRoot = function (event, cb) { 28 | // Register partials with Handlebars 29 | h.registerPartial('footer', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'footer.html'), 'utf8'))); 30 | h.registerPartial('header', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'header.html'), 'utf8'))); 31 | h.registerPartial('nav', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'nav.html'), 'utf8'))); 32 | 33 | // Render template with Handlebars 34 | var source = fs.readFileSync(path.join(__dirname, '..', 'views', 'index.html'), 'utf8'); 35 | var template = h.compile(source); 36 | var context = {basePath: helpers.getBasePath(process.env.SERVERLESS_STAGE), staticURL: process.env.STATIC_URL}; 37 | return cb(null, template(context)); 38 | }; 39 | 40 | // NAIP - States page 41 | module.exports.naipStates = function (event, cb) { 42 | // Get bucket name from STATIC_URL 43 | var params = { 44 | Bucket: helpers.getStaticBucket(), 45 | Key: 'uniques.json' 46 | }; 47 | s3.getObject(params, function (err, data) { 48 | var json = JSON.parse(data.Body.toString('utf8')); 49 | // var states = Object.keys(json); 50 | var states = []; 51 | for (var i = 0; i < Object.keys(json).length; i++) { 52 | var o = { 53 | state: Object.keys(json)[i], 54 | years: Object.keys(json[Object.keys(json)[i]]) 55 | }; 56 | states.push(o); 57 | } 58 | 59 | // Register partials with Handlebars 60 | h.registerPartial('footer', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'footer.html'), 'utf8'))); 61 | h.registerPartial('header', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'header.html'), 'utf8'))); 62 | h.registerPartial('nav', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'nav.html'), 'utf8'))); 63 | 64 | // Render template with Handlebars 65 | var source = fs.readFileSync(path.join(__dirname, '..', 'views', 'states.html'), 'utf8'); 66 | var template = h.compile(source); 67 | var context = {states: states, basePath: helpers.getBasePath(process.env.SERVERLESS_STAGE), staticURL: process.env.STATIC_URL}; 68 | return cb(err, template(context)); 69 | }); 70 | }; 71 | 72 | // NAIP - Quads page 73 | module.exports.naipQuads = function (event, cb) { 74 | // Get bucket name from STATIC_URL 75 | var params = { 76 | Bucket: helpers.getStaticBucket(), 77 | Key: 'uniques.json' 78 | }; 79 | s3.getObject(params, function (err, data) { 80 | var json = JSON.parse(data.Body.toString('utf8')); 81 | var quads = json[event.state][event.year]; 82 | 83 | // Set title here to get around templating issues 84 | var title = 'NAIP on AWS - Quads Available for ' + event.state + ' in ' + event.years; 85 | 86 | // Register partials with Handlebars 87 | h.registerPartial('footer', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'footer.html'), 'utf8'))); 88 | h.registerPartial('header', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'header.html'), 'utf8'))); 89 | h.registerPartial('nav', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'nav.html'), 'utf8'))); 90 | 91 | // Render template with Handlebars 92 | var source = fs.readFileSync(path.join(__dirname, '..', 'views', 'quads.html'), 'utf8'); 93 | var template = h.compile(source); 94 | var context = {title: title, quads: quads, state: event.state, year: event.year, basePath: helpers.getBasePath(process.env.SERVERLESS_STAGE), staticURL: process.env.STATIC_URL}; 95 | return cb(err, template(context)); 96 | }); 97 | }; 98 | 99 | // NAIP - Single quad page 100 | module.exports.naipQuad = function (event, cb) { 101 | var tasks = { 102 | files: function (done) { 103 | var params = { 104 | Bucket: 'aws-naip', 105 | Prefix: event.state + '/' + event.year + '/1m/rgb/100pct/' + event.quad + '/' 106 | }; 107 | s3.listObjects(params, function (err, data) { 108 | data = data.Contents.map(function (d) { 109 | return path.basename(d.Key, '.tif'); 110 | }); 111 | return done(err, data); 112 | }); 113 | } 114 | }; 115 | async.parallel(tasks, function (err, results) { 116 | // Register partials with Handlebars 117 | h.registerPartial('footer', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'footer.html'), 'utf8'))); 118 | h.registerPartial('header', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'header.html'), 'utf8'))); 119 | h.registerPartial('nav', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'nav.html'), 'utf8'))); 120 | 121 | // Set title here to get around templating issues 122 | var title = 'NAIP on AWS - ' + event.quad; 123 | 124 | // Render template with Handlebars 125 | var source = fs.readFileSync(path.join(__dirname, '..', 'views', 'quad.html'), 'utf8'); 126 | var template = h.compile(source); 127 | results.basePath = process.env.BASE_PATH; 128 | results.staticURL = process.env.STATIC_URL; 129 | var context = {state: event.state, year: event.year, quad: event.quad, files: results.files, title: title, basePath: helpers.getBasePath(process.env.SERVERLESS_STAGE), staticURL: process.env.STATIC_URL}; 130 | return cb(err, template(context)); 131 | }); 132 | }; 133 | 134 | // NAIP - Single scene page 135 | module.exports.naipScene = function (event, cb) { 136 | var tasks = { 137 | overviews100: function (done) { 138 | var params = { 139 | Bucket: 'aws-naip', 140 | Prefix: event.state + '/' + event.year + '/1m/rgb/100pct/' + event.quad + '/' + event.scene 141 | }; 142 | s3.listObjects(params, function (err, data) { 143 | data = data.Contents.map(function (d) { 144 | return {key: d.Key, filename: '100pct/' + path.basename(d.Key)}; 145 | }); 146 | return done(err, data); 147 | }); 148 | }, 149 | overviews50: function (done) { 150 | var params = { 151 | Bucket: 'aws-naip', 152 | Prefix: event.state + '/' + event.year + '/1m/rgb/50pct/' + event.quad + '/' + event.scene 153 | }; 154 | s3.listObjects(params, function (err, data) { 155 | data = data.Contents.map(function (d) { 156 | return {key: d.Key, filename: '50pct/' + path.basename(d.Key)}; 157 | }); 158 | return done(err, data); 159 | }); 160 | }, 161 | tiffs: function (done) { 162 | var params = { 163 | Bucket: 'aws-naip', 164 | Prefix: event.state + '/' + event.year + '/1m/rgbir/' + event.quad + '/' + event.scene 165 | }; 166 | s3.listObjects(params, function (err, data) { 167 | data = data.Contents.map(function (d) { 168 | return {key: d.Key, filename: path.basename(d.Key)}; 169 | }); 170 | return done(err, data); 171 | }); 172 | }, 173 | shapefiles: function (done) { 174 | var params = { 175 | Bucket: 'aws-naip', 176 | Prefix: event.state + '/' + event.year + '/1m/shpfl/' 177 | }; 178 | s3.listObjects(params, function (err, data) { 179 | data = data.Contents.map(function (d) { 180 | return {key: d.Key, filename: path.basename(d.Key)}; 181 | }); 182 | return done(err, data); 183 | }); 184 | }, 185 | metadata: function (done) { 186 | var params = { 187 | Bucket: 'aws-naip', 188 | Prefix: event.state + '/' + event.year + '/1m/fgdc/' + event.quad + '/' + event.scene 189 | }; 190 | s3.listObjects(params, function (err, data) { 191 | data = data.Contents.map(function (d) { 192 | return {key: d.Key, filename: path.basename(d.Key)}; 193 | }); 194 | return done(err, data); 195 | }); 196 | } 197 | }; 198 | async.parallel(tasks, function (err, results) { 199 | var scene = { 200 | id: event.scene, 201 | files: {} 202 | }; 203 | 204 | // Register partials with Handlebars 205 | h.registerPartial('footer', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'footer.html'), 'utf8'))); 206 | h.registerPartial('header', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'header.html'), 'utf8'))); 207 | h.registerPartial('nav', (fs.readFileSync(path.join(__dirname, '..', 'views', 'partials', 'nav.html'), 'utf8'))); 208 | 209 | // Set title here to get around templating issues 210 | var title = 'NAIP on AWS - ' + event.quad; 211 | 212 | // Bin files into specific groups 213 | scene.files.tiffs = results.tiffs; 214 | scene.files.shapefiles = results.shapefiles; 215 | scene.files.overviews = results.overviews50.concat(results.overviews100); 216 | scene.files.metadata = results.metadata; 217 | console.log(scene); 218 | // Render template with Handlebars 219 | var source = fs.readFileSync(path.join(__dirname, '..', 'views', 'scene.html'), 'utf8'); 220 | var template = h.compile(source); 221 | results.basePath = process.env.BASE_PATH; 222 | results.staticURL = process.env.STATIC_URL; 223 | var context = {state: event.state, year: event.year, quad: event.quad, scene: scene, title: title, basePath: helpers.getBasePath(process.env.SERVERLESS_STAGE), staticURL: process.env.STATIC_URL}; 224 | return cb(err, template(context)); 225 | }); 226 | }; 227 | 228 | // NAIP - provide signed url 229 | module.exports.getSignedURL = function (event, cb) { 230 | var tasks = { 231 | url: function (done) { 232 | var params = { 233 | Bucket: 'aws-naip', 234 | Key: event.key, 235 | Expires: 10 236 | }; 237 | s3.getSignedUrl('getObject', params, function (err, url) { 238 | return done(err, url); 239 | }); 240 | }, 241 | metadata: function (done) { 242 | var params = { 243 | Bucket: 'aws-naip', 244 | Key: event.key 245 | }; 246 | s3.headObject(params, function (err, data) { 247 | return done(err, data); 248 | }); 249 | } 250 | }; 251 | async.parallel(tasks, function (err, results) { 252 | // Can now access size of object with results.metadata.ContentLength 253 | return cb(err, {url: results.url}); 254 | }); 255 | }; 256 | -------------------------------------------------------------------------------- /restApi/lib/throttle.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Functions related to updating of site metadata. 16 | */ 17 | 18 | 'use strict'; 19 | 20 | var AWS = require('aws-sdk'); 21 | var apigateway = new AWS.APIGateway(); 22 | 23 | var baseRate = 1000; // Base level requests / second 24 | var baseBurst = 2000; // Base level of burst 25 | var throttledRate = 2; // Throttled level requests / second 26 | var throttledBurst = 4; // Throttled level of burst 27 | 28 | module.exports.reset = function (event, cb) { 29 | console.info('Resetting throttle limits to default.'); 30 | setThrottleLimits(baseRate, baseBurst, function (err, response) { 31 | return cb(err, response); 32 | }); 33 | }; 34 | 35 | module.exports.limit = function (event, cb) { 36 | console.info('Throttling down API.'); 37 | setThrottleLimits(throttledRate, throttledBurst, function (err) { 38 | return cb(err, 'done'); 39 | }); 40 | }; 41 | 42 | var setThrottleLimits = function (rate, burst, cb) { 43 | var params = { 44 | restApiId: process.env.API_GATEWAY_ID, 45 | stageName: process.env.SERVERLESS_STAGE, 46 | patchOperations: [ 47 | { 48 | op: 'replace', 49 | path: '/d/GET/throttling/rateLimit', 50 | value: rate.toString() 51 | }, 52 | { 53 | op: 'replace', 54 | path: '/d/GET/throttling/burstLimit', 55 | value: burst.toString() 56 | } 57 | ] 58 | }; 59 | apigateway.updateStage(params, function (err, data) { 60 | return cb(err); 61 | }); 62 | }; 63 | -------------------------------------------------------------------------------- /restApi/lib/updater.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Functions related to updating of site metadata. 16 | */ 17 | 18 | 'use strict'; 19 | 20 | var AWS = require('aws-sdk'); 21 | var s3 = new AWS.S3(); 22 | var fs = require('fs'); 23 | var parse = require('csv-parse'); 24 | var async = require('async'); 25 | var helpers = require('./helpers'); 26 | var _ = require('lodash'); 27 | 28 | var filesList = '/tmp/manifest.txt'; // Where to store list of all NAIP scenes 29 | var uniquesFile = 'uniques.json'; // Filename for combos 30 | 31 | module.exports.update = function (event, cb) { 32 | // Download data from S3 33 | console.info('Getting latest manifest from S3!'); 34 | var params = { 35 | Bucket: 'aws-naip', 36 | Key: 'manifest.txt', 37 | RequestPayer: 'requester' 38 | }; 39 | s3.getObject(params, function (err, data) { 40 | if (err) { 41 | return cb(err); 42 | } 43 | console.info('Saving manifest to disk.'); 44 | fs.writeFileSync(filesList, data.Body.toString()); 45 | processData(function (err, results) { 46 | return cb(err, results); 47 | }); 48 | }); 49 | }; 50 | 51 | var processData = function (cb) { 52 | console.info('Reading in scenes data from ' + filesList); 53 | var input = fs.createReadStream(filesList); 54 | var parser = parse(); 55 | input.pipe(parser); 56 | var obj = {}; 57 | parser.on('data', function (data) { 58 | // This is dataset specific, turn into an object we can work with 59 | var file = data[0]; 60 | var parts = _.initial(file.split('/')); 61 | if (parts.indexOf('rgb') !== -1 && parts.indexOf('100pct') !== -1) { 62 | obj[parts[0]] = obj[parts[0]] || {}; 63 | obj[parts[0]][parts[1]] = obj[parts[0]][parts[1]] || []; 64 | if (obj[parts[0]][parts[1]].indexOf(parts[5]) === -1) { 65 | obj[parts[0]][parts[1]].push(parts[5]); 66 | } 67 | } 68 | }); 69 | 70 | parser.on('finish', function () { 71 | console.info('Built up unique manifest object internally, writing out files to S3.'); 72 | var tasks = [ 73 | function (done) { 74 | writeUniques(obj, done); 75 | } 76 | ]; 77 | async.parallel(tasks, function (err, results) { 78 | if (err) { 79 | return cb(err); 80 | } 81 | console.info('All done!'); 82 | return cb(null, 'done'); 83 | }); 84 | }); 85 | 86 | var writeUniques = function (data, cb) { 87 | console.info('Writing uniques ' + uniquesFile); 88 | writeToS3(uniquesFile, JSON.stringify(data), function (err) { 89 | console.info('Wrote unique combos to ' + uniquesFile); 90 | return cb(err); 91 | }); 92 | }; 93 | }; 94 | 95 | var writeToS3 = function (key, data, cb) { 96 | s3.putObject({ 97 | 'Bucket': helpers.getStaticBucket(), 98 | 'Key': key, 99 | 'Body': data, 100 | 'ACL': 'public-read' 101 | }, function (err) { 102 | return cb(err); 103 | }); 104 | }; 105 | -------------------------------------------------------------------------------- /restApi/naip/download/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "co/2013/1m/rgbir/36102/m_3610201_ne_13_1_20130704.tif" 3 | } -------------------------------------------------------------------------------- /restApi/naip/download/handler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | 'use strict'; 15 | 16 | /** 17 | * Serverless Module: Lambda Handler 18 | * - Your lambda functions should be a thin wrapper around your own separate 19 | * modules, to keep your code testable, reusable and AWS independent 20 | * - 'serverless-helpers-js' module is required for Serverless ENV var support. Hopefully, AWS will add ENV support to Lambda soon :) 21 | */ 22 | 23 | // Require Logic 24 | var lib = require('../../lib'); 25 | 26 | // Lambda Handler 27 | module.exports.handler = function (event, context) { 28 | lib.getSignedURL(event, function (error, response) { 29 | return context.done(error, response); 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /restApi/naip/download/s-function.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "naip-download", 3 | "runtime": "nodejs4.3", 4 | "description": "Handler for downloading", 5 | "customName": false, 6 | "customRole": false, 7 | "handler": "naip/download/handler.handler", 8 | "timeout": 6, 9 | "memorySize": 256, 10 | "authorizer": {}, 11 | "custom": { 12 | "excludePatterns": [], 13 | "envVars": [], 14 | "optimize": { 15 | "transforms": [ 16 | "brfs" 17 | ], 18 | "exclude": [ 19 | "aws-sdk" 20 | ] 21 | } 22 | }, 23 | "endpoints": [ 24 | { 25 | "path": "/d", 26 | "method": "GET", 27 | "type": "AWS", 28 | "authorizationType": "none", 29 | "authorizerFunction": false, 30 | "apiKeyRequired": false, 31 | "requestParameters": {}, 32 | "requestTemplates": "$${apiRequestTemplate}", 33 | "responses": { 34 | "400": { 35 | "statusCode": "400" 36 | }, 37 | "default": { 38 | "statusCode": "301", 39 | "responseParameters": { 40 | "method.response.header.Location": "integration.response.body.url" 41 | }, 42 | "responseModels": { 43 | "text/html": "Empty" 44 | }, 45 | "responseTemplates": {} 46 | } 47 | } 48 | } 49 | ], 50 | "events": [], 51 | "environment": { 52 | "SERVERLESS_PROJECT": "${project}", 53 | "SERVERLESS_STAGE": "${stage}", 54 | "SERVERLESS_REGION": "${region}", 55 | "STATIC_URL": "${staticURL}" 56 | }, 57 | "vpc": { 58 | "securityGroupIds": [], 59 | "subnetIds": [] 60 | } 61 | } -------------------------------------------------------------------------------- /restApi/naip/download/s-templates.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiRequestTemplate": { 3 | "application/json": { 4 | "key": "$input.params('key')" 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /restApi/naip/quad/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "state": "co", 3 | "year": "2013", 4 | "quad": "36102" 5 | } -------------------------------------------------------------------------------- /restApi/naip/quad/handler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | 'use strict'; 15 | 16 | /** 17 | * Serverless Module: Lambda Handler 18 | * - Your lambda functions should be a thin wrapper around your own separate 19 | * modules, to keep your code testable, reusable and AWS independent 20 | * - 'serverless-helpers-js' module is required for Serverless ENV var support. Hopefully, AWS will add ENV support to Lambda soon :) 21 | */ 22 | 23 | // Require Logic 24 | var lib = require('../../lib'); 25 | 26 | // Lambda Handler 27 | module.exports.handler = function (event, context) { 28 | lib.naipQuad(event, function (error, response) { 29 | return context.done(error, response); 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /restApi/naip/quad/s-function.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "naip-quad", 3 | "runtime": "nodejs4.3", 4 | "description": "Handler for quad page", 5 | "customName": false, 6 | "customRole": false, 7 | "handler": "naip/quad/handler.handler", 8 | "timeout": 6, 9 | "memorySize": 256, 10 | "authorizer": {}, 11 | "custom": { 12 | "excludePatterns": [], 13 | "envVars": [], 14 | "optimize": { 15 | "transforms": [ 16 | "brfs" 17 | ], 18 | "exclude": [ 19 | "aws-sdk" 20 | ] 21 | } 22 | }, 23 | "endpoints": [ 24 | { 25 | "path": "/{state}/{year}/{quad}", 26 | "method": "GET", 27 | "type": "AWS", 28 | "authorizationType": "none", 29 | "authorizerFunction": false, 30 | "apiKeyRequired": false, 31 | "requestParameters": {}, 32 | "requestTemplates": "$${apiRequestTemplate}", 33 | "responses": { 34 | "400": { 35 | "statusCode": "400" 36 | }, 37 | "default": { 38 | "statusCode": "200", 39 | "responseParameters": {}, 40 | "responseModels": { 41 | "text/html": "Empty" 42 | }, 43 | "responseTemplates": { 44 | "text/html": "#set($inputRoot = $input.path('$'))$inputRoot" 45 | } 46 | } 47 | } 48 | } 49 | ], 50 | "events": [], 51 | "environment": { 52 | "SERVERLESS_PROJECT": "${project}", 53 | "SERVERLESS_STAGE": "${stage}", 54 | "SERVERLESS_REGION": "${region}", 55 | "STATIC_URL": "${staticURL}" 56 | }, 57 | "vpc": { 58 | "securityGroupIds": [], 59 | "subnetIds": [] 60 | } 61 | } -------------------------------------------------------------------------------- /restApi/naip/quad/s-templates.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiRequestTemplate": { 3 | "application/json": { 4 | "state": "$input.params('state')", 5 | "year": "$input.params('year')", 6 | "quad": "$input.params('quad')" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /restApi/naip/quads/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "state": "co", 3 | "year": "2013" 4 | } -------------------------------------------------------------------------------- /restApi/naip/quads/handler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | 'use strict'; 15 | 16 | /** 17 | * Serverless Module: Lambda Handler 18 | * - Your lambda functions should be a thin wrapper around your own separate 19 | * modules, to keep your code testable, reusable and AWS independent 20 | * - 'serverless-helpers-js' module is required for Serverless ENV var support. Hopefully, AWS will add ENV support to Lambda soon :) 21 | */ 22 | 23 | // Require Logic 24 | var lib = require('../../lib'); 25 | 26 | // Lambda Handler 27 | module.exports.handler = function (event, context) { 28 | lib.naipQuads(event, function (error, response) { 29 | return context.done(error, response); 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /restApi/naip/quads/s-function.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "naip-quads", 3 | "runtime": "nodejs4.3", 4 | "description": "Handler for quads page", 5 | "customName": false, 6 | "customRole": false, 7 | "handler": "naip/quads/handler.handler", 8 | "timeout": 6, 9 | "memorySize": 256, 10 | "authorizer": {}, 11 | "custom": { 12 | "excludePatterns": [], 13 | "envVars": [], 14 | "optimize": { 15 | "transforms": [ 16 | "brfs" 17 | ], 18 | "exclude": [ 19 | "aws-sdk" 20 | ] 21 | } 22 | }, 23 | "endpoints": [ 24 | { 25 | "path": "/{state}/{year}", 26 | "method": "GET", 27 | "type": "AWS", 28 | "authorizationType": "none", 29 | "authorizerFunction": false, 30 | "apiKeyRequired": false, 31 | "requestParameters": {}, 32 | "requestTemplates": "$${apiRequestTemplate}", 33 | "responses": { 34 | "400": { 35 | "statusCode": "400" 36 | }, 37 | "default": { 38 | "statusCode": "200", 39 | "responseParameters": {}, 40 | "responseModels": { 41 | "text/html": "Empty" 42 | }, 43 | "responseTemplates": { 44 | "text/html": "#set($inputRoot = $input.path('$'))$inputRoot" 45 | } 46 | } 47 | } 48 | } 49 | ], 50 | "events": [], 51 | "environment": { 52 | "SERVERLESS_PROJECT": "${project}", 53 | "SERVERLESS_STAGE": "${stage}", 54 | "SERVERLESS_REGION": "${region}", 55 | "STATIC_URL": "${staticURL}" 56 | }, 57 | "vpc": { 58 | "securityGroupIds": [], 59 | "subnetIds": [] 60 | } 61 | } -------------------------------------------------------------------------------- /restApi/naip/quads/s-templates.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiRequestTemplate": { 3 | "application/json": { 4 | "state": "$input.params('state')", 5 | "year": "$input.params('year')" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /restApi/naip/root/event.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /restApi/naip/root/handler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | 'use strict'; 15 | 16 | /** 17 | * Serverless Module: Lambda Handler 18 | * - Your lambda functions should be a thin wrapper around your own separate 19 | * modules, to keep your code testable, reusable and AWS independent 20 | * - 'serverless-helpers-js' module is required for Serverless ENV var support. Hopefully, AWS will add ENV support to Lambda soon :) 21 | */ 22 | 23 | // Require Logic 24 | var lib = require('../../lib'); 25 | 26 | // Lambda Handler 27 | module.exports.handler = function (event, context) { 28 | lib.naipRoot(event, function (error, response) { 29 | return context.done(error, response); 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /restApi/naip/root/s-function.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "naip-index", 3 | "runtime": "nodejs4.3", 4 | "description": "Handler for root and sitemap proxies", 5 | "customName": false, 6 | "customRole": false, 7 | "handler": "naip/root/handler.handler", 8 | "timeout": 6, 9 | "memorySize": 256, 10 | "authorizer": {}, 11 | "custom": { 12 | "excludePatterns": [], 13 | "envVars": [], 14 | "optimize": { 15 | "transforms": [ 16 | "brfs" 17 | ], 18 | "exclude": [ 19 | "aws-sdk" 20 | ] 21 | } 22 | }, 23 | "endpoints": [ 24 | { 25 | "path": "/", 26 | "method": "GET", 27 | "type": "AWS", 28 | "authorizationType": "none", 29 | "authorizerFunction": false, 30 | "apiKeyRequired": false, 31 | "requestParameters": {}, 32 | "requestTemplates": "$${apiRequestTemplate}", 33 | "responses": { 34 | "400": { 35 | "statusCode": "400" 36 | }, 37 | "default": { 38 | "statusCode": "200", 39 | "responseParameters": {}, 40 | "responseModels": { 41 | "text/html": "Empty" 42 | }, 43 | "responseTemplates": { 44 | "text/html": "#set($inputRoot = $input.path('$'))$inputRoot" 45 | } 46 | } 47 | } 48 | }, 49 | { 50 | "path": "/sitemap.txt", 51 | "method": "GET", 52 | "type": "HTTP", 53 | "authorizationType": "none", 54 | "authorizerFunction": false, 55 | "apiKeyRequired": false, 56 | "requestParameters": {}, 57 | "requestTemplates": "$${apiRequestTemplate}", 58 | "responses": { 59 | "400": { 60 | "statusCode": "400" 61 | }, 62 | "default": { 63 | "statusCode": "200", 64 | "responseParameters": {}, 65 | "responseModels": { 66 | "text/html": "Empty" 67 | }, 68 | "responseTemplates": { 69 | "text/html": "#set($inputRoot = $input.path('$'))$inputRoot" 70 | } 71 | } 72 | }, 73 | "targetMethod": "GET", 74 | "uri": "${staticURL}sitemap.txt" 75 | } 76 | ], 77 | "events": [], 78 | "environment": { 79 | "SERVERLESS_PROJECT": "${project}", 80 | "SERVERLESS_STAGE": "${stage}", 81 | "SERVERLESS_REGION": "${region}", 82 | "STATIC_URL": "${staticURL}" 83 | }, 84 | "vpc": { 85 | "securityGroupIds": [], 86 | "subnetIds": [] 87 | } 88 | } -------------------------------------------------------------------------------- /restApi/naip/root/s-templates.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiRequestTemplate": { 3 | "application/json": {} 4 | } 5 | } -------------------------------------------------------------------------------- /restApi/naip/scene/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "state": "co", 3 | "year": "2013", 4 | "quad": "36102", 5 | "scene": "m_3610201_ne_13_1_20130704" 6 | } -------------------------------------------------------------------------------- /restApi/naip/scene/handler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | 'use strict'; 15 | 16 | /** 17 | * Serverless Module: Lambda Handler 18 | * - Your lambda functions should be a thin wrapper around your own separate 19 | * modules, to keep your code testable, reusable and AWS independent 20 | * - 'serverless-helpers-js' module is required for Serverless ENV var support. Hopefully, AWS will add ENV support to Lambda soon :) 21 | */ 22 | 23 | // Require Logic 24 | var lib = require('../../lib'); 25 | 26 | // Lambda Handler 27 | module.exports.handler = function (event, context) { 28 | lib.naipScene(event, function (error, response) { 29 | return context.done(error, response); 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /restApi/naip/scene/s-function.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "naip-scene", 3 | "runtime": "nodejs4.3", 4 | "description": "Handler for scene page", 5 | "customName": false, 6 | "customRole": false, 7 | "handler": "naip/scene/handler.handler", 8 | "timeout": 6, 9 | "memorySize": 256, 10 | "authorizer": {}, 11 | "custom": { 12 | "excludePatterns": [], 13 | "envVars": [], 14 | "optimize": { 15 | "transforms": [ 16 | "brfs" 17 | ], 18 | "exclude": [ 19 | "aws-sdk" 20 | ] 21 | } 22 | }, 23 | "endpoints": [ 24 | { 25 | "path": "/{state}/{year}/{quad}/{scene}", 26 | "method": "GET", 27 | "type": "AWS", 28 | "authorizationType": "none", 29 | "authorizerFunction": false, 30 | "apiKeyRequired": false, 31 | "requestParameters": {}, 32 | "requestTemplates": "$${apiRequestTemplate}", 33 | "responses": { 34 | "400": { 35 | "statusCode": "400" 36 | }, 37 | "default": { 38 | "statusCode": "200", 39 | "responseParameters": {}, 40 | "responseModels": { 41 | "text/html": "Empty" 42 | }, 43 | "responseTemplates": { 44 | "text/html": "#set($inputRoot = $input.path('$'))$inputRoot" 45 | } 46 | } 47 | } 48 | } 49 | ], 50 | "events": [], 51 | "environment": { 52 | "SERVERLESS_PROJECT": "${project}", 53 | "SERVERLESS_STAGE": "${stage}", 54 | "SERVERLESS_REGION": "${region}", 55 | "STATIC_URL": "${staticURL}" 56 | }, 57 | "vpc": { 58 | "securityGroupIds": [], 59 | "subnetIds": [] 60 | } 61 | } -------------------------------------------------------------------------------- /restApi/naip/scene/s-templates.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiRequestTemplate": { 3 | "application/json": { 4 | "state": "$input.params('state')", 5 | "year": "$input.params('year')", 6 | "quad": "$input.params('quad')", 7 | "scene": "$input.params('scene')" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /restApi/naip/states/event.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /restApi/naip/states/handler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | 'use strict'; 15 | 16 | /** 17 | * Serverless Module: Lambda Handler 18 | * - Your lambda functions should be a thin wrapper around your own separate 19 | * modules, to keep your code testable, reusable and AWS independent 20 | * - 'serverless-helpers-js' module is required for Serverless ENV var support. Hopefully, AWS will add ENV support to Lambda soon :) 21 | */ 22 | 23 | // Require Logic 24 | var lib = require('../../lib'); 25 | 26 | // Lambda Handler 27 | module.exports.handler = function (event, context) { 28 | lib.naipStates(event, function (error, response) { 29 | return context.done(error, response); 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /restApi/naip/states/s-function.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "naip-states", 3 | "runtime": "nodejs4.3", 4 | "description": "Handler for states page", 5 | "customName": false, 6 | "customRole": false, 7 | "handler": "naip/states/handler.handler", 8 | "timeout": 6, 9 | "memorySize": 256, 10 | "authorizer": {}, 11 | "custom": { 12 | "excludePatterns": [], 13 | "envVars": [], 14 | "optimize": { 15 | "transforms": [ 16 | "brfs" 17 | ], 18 | "exclude": [ 19 | "aws-sdk" 20 | ] 21 | } 22 | }, 23 | "endpoints": [ 24 | { 25 | "path": "/states", 26 | "method": "GET", 27 | "type": "AWS", 28 | "authorizationType": "none", 29 | "authorizerFunction": false, 30 | "apiKeyRequired": false, 31 | "requestParameters": {}, 32 | "requestTemplates": "$${apiRequestTemplate}", 33 | "responses": { 34 | "400": { 35 | "statusCode": "400" 36 | }, 37 | "default": { 38 | "statusCode": "200", 39 | "responseParameters": {}, 40 | "responseModels": { 41 | "text/html": "Empty" 42 | }, 43 | "responseTemplates": { 44 | "text/html": "#set($inputRoot = $input.path('$'))$inputRoot" 45 | } 46 | } 47 | } 48 | } 49 | ], 50 | "events": [], 51 | "environment": { 52 | "SERVERLESS_PROJECT": "${project}", 53 | "SERVERLESS_STAGE": "${stage}", 54 | "SERVERLESS_REGION": "${region}", 55 | "STATIC_URL": "${staticURL}" 56 | }, 57 | "vpc": { 58 | "securityGroupIds": [], 59 | "subnetIds": [] 60 | } 61 | } -------------------------------------------------------------------------------- /restApi/naip/throttle/event.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /restApi/naip/throttle/handler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | 'use strict'; 15 | 16 | /** 17 | * Serverless Module: Lambda Handler 18 | * - Your lambda functions should be a thin wrapper around your own separate 19 | * modules, to keep your code testable, reusable and AWS independent 20 | * - 'serverless-helpers-js' module is required for Serverless ENV var support. Hopefully, AWS will add ENV support to Lambda soon :) 21 | */ 22 | 23 | // Require Logic 24 | var throttle = require('../../lib/throttle'); 25 | 26 | // Lambda Handler 27 | module.exports.handler = function (event, context) { 28 | // Branch depending on whether this is a scheduled event or from SNS topic 29 | if (event.source === 'aws.events') { 30 | throttle.reset(event, function (error, response) { 31 | return context.done(error, response); 32 | }); 33 | } else if (event.Records && event.Records[0] && event.Records[0].EventSource === 'aws:sns') { 34 | throttle.limit(event, function (error, response) { 35 | return context.done(error, response); 36 | }); 37 | } else { 38 | return context.done('Unknown invoker'); 39 | } 40 | }; 41 | -------------------------------------------------------------------------------- /restApi/naip/throttle/s-function.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "naip-throttle", 3 | "runtime": "nodejs4.3", 4 | "description": "Throttle the downloads endpoint.", 5 | "customName": false, 6 | "customRole": false, 7 | "handler": "naip/throttle/handler.handler", 8 | "timeout": 20, 9 | "memorySize": 128, 10 | "authorizer": {}, 11 | "custom": { 12 | "excludePatterns": [], 13 | "envVars": [], 14 | "optimize": { 15 | "exclude": [ 16 | "aws-sdk" 17 | ] 18 | } 19 | }, 20 | "endpoints": [], 21 | "events": [ 22 | { 23 | "name": "monthlyReset", 24 | "type": "schedule", 25 | "config": { 26 | "schedule": "cron(0 0 1 * ? *)", 27 | "enabled": true 28 | } 29 | }, 30 | { 31 | "name" : "limitReached", 32 | "type": "sns", 33 | "config": { 34 | "topicName": "arn:aws:sns:us-east-1:947081328633:naip-on-aws-s3-egress" 35 | } 36 | } 37 | ], 38 | "environment": { 39 | "SERVERLESS_PROJECT": "${project}", 40 | "SERVERLESS_STAGE": "${stage}", 41 | "SERVERLESS_REGION": "${region}", 42 | "BASE_URL": "${baseURL}", 43 | "STATIC_URL": "${staticURL}", 44 | "API_GATEWAY_ID": "${apiGatewayId}" 45 | }, 46 | "vpc": { 47 | "securityGroupIds": [], 48 | "subnetIds": [] 49 | } 50 | } -------------------------------------------------------------------------------- /restApi/naip/updater/event.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /restApi/naip/updater/handler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in 5 | * compliance with the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0/ 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | 'use strict'; 15 | 16 | /** 17 | * Serverless Module: Lambda Handler 18 | * - Your lambda functions should be a thin wrapper around your own separate 19 | * modules, to keep your code testable, reusable and AWS independent 20 | * - 'serverless-helpers-js' module is required for Serverless ENV var support. Hopefully, AWS will add ENV support to Lambda soon :) 21 | */ 22 | 23 | // Require Logic 24 | var updater = require('../../lib/updater'); 25 | 26 | // Lambda Handler 27 | module.exports.handler = function (event, context) { 28 | updater.update(event, function (error, response) { 29 | return context.done(error, response); 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /restApi/naip/updater/s-function.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "naip-updater", 3 | "runtime": "nodejs4.3", 4 | "description": "Update static data on S3.", 5 | "customName": false, 6 | "customRole": false, 7 | "handler": "naip/updater/handler.handler", 8 | "timeout": 180, 9 | "memorySize": 1536, 10 | "authorizer": {}, 11 | "custom": { 12 | "excludePatterns": [], 13 | "envVars": [], 14 | "optimize": { 15 | "exclude": [ 16 | "aws-sdk" 17 | ] 18 | } 19 | }, 20 | "endpoints": [], 21 | "events": [ 22 | { 23 | "name": "dailyUpdate", 24 | "type": "schedule", 25 | "config": { 26 | "schedule": "rate(6 hours)", 27 | "enabled": true 28 | } 29 | } 30 | ], 31 | "environment": { 32 | "SERVERLESS_PROJECT": "${project}", 33 | "SERVERLESS_STAGE": "${stage}", 34 | "SERVERLESS_REGION": "${region}", 35 | "BASE_URL": "${baseURL}", 36 | "STATIC_URL": "${staticURL}" 37 | }, 38 | "vpc": { 39 | "securityGroupIds": [], 40 | "subnetIds": [] 41 | } 42 | } -------------------------------------------------------------------------------- /restApi/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{> header title='NAIP on AWS'}} 5 | 6 |
7 |NAIP on AWS makes National Agriculture Imagery Program (NAIP) data available for anyone to use via Amazon S3. The National Agriculture Imagery Program (NAIP) acquires aerial imagery during the agricultural growing seasons in the continental U.S. Roughly one meter aerial imagery (Red, Green, Blue, NIR) is available for multiple years on Amazon S3.
14 |This site allows you to browse all NAIP imagery available on AWS.
15 |The National Agriculture Imagery Program is administered by the USDA's Farm Service Agency (FSA) through the Aerial Photography Field Office in Salt Lake City.
27 |Learn more at USDA's NAIP page.
28 | 29 |All data is available in the aws-naip
Amazon S3 bucket in the in US East AWS Region. Data is optimized for programattic access from Amazon EC2.
More information on accessing NAIP on AWS.
32 |A variety of Earth observation and environmental datasets are available at no cost on AWS. Analyze data without needing to download or store your own copy.
37 |Learn more about Earth on AWS.
38 | 39 |This site uses AWS Lambda and Amazon API Gateway to create web pages on demand without maintaining any servers.
41 |Learn more on the AWS Compute blog.
42 |NAIP on AWS / {{state}} / {{year}} / {{quad}}
11 |NAIP on AWS / {{state}} / {{year}}
11 |NAIP on AWS / {{state}} / {{year}} / {{quad}} / {{scene.id}}
11 |