Functions as a Service

Sometimes you need to do computations that may require resources or compute power beyond what can be expected in the cient browser. This is where Functions as a Service come into play in the Serverless world. This section is about writing those little functions.

AD

AD

Build, Package and Deploy Function

You'll need to map the web request to a json format consumable by Lambda. http://docs.aws.amazon.com/lambda/latest/dg/java-handler-using-predefined-interfaces.html

AD

AD

Add Function to API Manager

http://stackoverflow.com/questions/31329958/how-to-pass-a-querystring-or-route-parameter-to-aws-lambda-from-amazon-api-gatew

AD

AD

Call the function!

Name:

Result will appear here

If you want to test this locally from localhost, then you need to set CORS headers: http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html#how-to-cors-console Don't forget to redeploy after setting this up.

AD

AD

Give it a friendly URL

http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html

You'll need an SSL certificate: https://aws.amazon.com/certificate-manager/ looks nice but at the time of writing:

  1. To use an ACM Certificate with CloudFront, you must request the certificate in the US East (N. Virginia) region. Not a problem.
  2. You need to have access to the certificate body and key. On the roadmap (or some better integration?) but not available yet: https://forums.aws.amazon.com/thread.jspa?threadID=234686

So you'll need to get a key from another provider and enter it in API Gateway. Generate a Certificate Signing Request (CSR) using: openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr

Follow the onscreen instructions and then upload the CSR to your chosen certificate provider (I use GoDaddy, other providers are available.) You will then (after paying some money) recieve a certificate, and a certificate chain which can be uploaded to API Gateway. Now just create an alias for e.g. api.yourdomain.com to point to the cloudfront endpoint created by API Gateway. Note that you no longer need the stage name as part of the url, as the API Gateway mapping hides that away. Again, you'll need to redeploy the API for the certificate change to take effect.
Name:

Result will appear here

AD

AD