In order of first appearance in The Morning Paper.
--- | |
Description: AWSAppSync DynamoDB Example | |
Resources: | |
GraphQLApi: | |
Type: "AWS::AppSync::GraphQLApi" | |
Properties: | |
Name: AWSAppSync DynamoDB Example | |
AuthenticationType: AWS_IAM | |
PostDynamoDBTableDataSource: |
import React, { PureComponent } from 'react' | |
import Grid from 'material-ui/Grid' | |
import { CardNumberElement, CardExpiryElement, CardCVCElement } from 'react-stripe-elements' | |
import StripeElementWrapper from './StripeElementWrapper' | |
export default class extends PureComponent { | |
static displayName = 'StripeCardsSection' |
⚠ This post is fairly old. I don't keep it up to date. Be sure to see comments where some people have posted updates
What this will cover
- Host a static website at S3
- Redirect
www.website.com
towebsite.com
- Website can be an SPA (requiring all requests to return
index.html
) - Free AWS SSL certs
- Deployment with CDN invalidation
In general, the command ldd and the environment variable LD_LINKER_PATH
is your best friend when running new, untested binaries in Lambda. My process (which I want to get around to automating one day, maybe using Packer), goes like this:
- Run an EC2 instance with the official AWS Lambda AMI.
- Get binary you want to run in AWS Lambda running on the instance (either by installing from a package manager or compiling).
- Run
ldd -v ./the-binary
. Note all of the shared libraries it requires. You’ll need to remember these. - Copy the binary to your local machine. Upload the binary with your AWS Lambda function code that runs the ldd command inside the handler function using the process execution library from your language of choice. In node, this works just fine:
console.log(require('child_process').execSync('ldd -v ./the-binary'))
- Note any shared libraries that are missing in the function output. Copy those over from the EC2 instance to a direct
┌──────────┐ | |
──┤ Overview ├───────────────────────────────────────────────────────────────── | |
└──────────┘ | |
$ npm install --save bluebird | |
const Promise = require('bluebird') |
/* | |
* Handling Errors using async/await | |
* Has to be used inside an async function | |
*/ | |
try { | |
const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
// Success 🎉 | |
console.log(response); | |
} catch (error) { | |
// Error 😨 |
There is a trending 'microservice' library called go-kit. I've been using the go-kit library for a while now. The library provide a lot of convenience integrations that you might need in your service: with service discovery with Consul, distributed tracing with Zipkin, for example, and nice logic utilities such as round robin client side load balancing, and circuit breaking. It is also providing a way to implement communication layer, with support of RPC and REST.
#!/bin/bash | |
# wrapper around "aws cloudformation" CLI to ignore certain pseudo-errors | |
# aws cloudformation deploy exits with 255 for "No changes to deploy" see: https://github.com/awslabs/serverless-application-model/issues/71 | |
# this script exits with 0 for that case | |
STDERR=$(( aws cloudformation "$@" ) 2>&1) | |
ERROR_CODE=$? | |
echo ${STDERR} 1>&2 |
If you use atom... download & install the following packages: