Skip to content

Instantly share code, notes, and snippets.

@alexdebrie
alexdebrie / README.md
Created February 1, 2019 01:59
Using boto3 generate_presigned_post()

Using an S3 presigned POST url.

  1. Copy the generate.py script to your machine.

  2. Update the BUCKET_NAME and KEY_NAME values in the script as needed.

  3. Run python generate.py. It will spit some output like the following:

$ python3 generate.py

functions:
hello:
handler: handler.hello
events:
- http:
path: hello
method: get
cors:
origin: 'api.myorigin.com'
headers:
@alexdebrie
alexdebrie / handler.js
Created January 11, 2018 16:53
Middy CORS example
# handler.js
const middy = require('middy')
const { cors } = require('middy/middlewares')
// This is your common handler, no way different than what you are used to do every day
// in AWS Lambda
const processPayment = (event, context, callback) => {
// we don't need to deserialize the body ourself as a middleware will be used to do that
const { creditCardNumber, expiryMonth, expiryYear, cvc, nameOnCard, amount } = event.body