Skip to content

Instantly share code, notes, and snippets.

View Magrath's full-sized avatar
The coffee must flow.

Paul Magrath Magrath

The coffee must flow.
View GitHub Profile
@Magrath
Magrath / GetDecryptAndEncrypt.go
Last active July 21, 2017 12:26
Retrieving, decrypting from and then re-encrypting to S3 using KMS client side decryption
package main
import (
"bytes"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/client"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kms"
"github.com/aws/aws-sdk-go/service/s3"
@Magrath
Magrath / GetAndDecrypt.rb
Last active October 12, 2017 15:00
Retrieving and decrypting from S3 using KMS client side decryption
def get(bucket, s3_key)
client = Aws::S3::Client.new(region: "us-east-1")
params = { bucket: bucket, key: s3_key }
req = client.build_request(:get_object, params)
req.send_request
end
def decrypt(get_object_output, kms_key_id)
cipher_provider = Aws::S3::Encryption::KmsCipherProvider.new(kms_key_id: kms_key_id, kms_client: Aws::KMS::Client.new)
envelope = get_object_output.metadata
@Magrath
Magrath / Makefile
Last active August 29, 2015 14:16
Basic Makefile for Go 1.4 projects
go ?= go
build: fmt lint vet
$(go) build ./...
fmt:
$(go) fmt ./...
lint:
$(go) get github.com/golang/lint/golint
### Keybase proof
I hereby claim:
* I am magrath on github.
* I am magrath (https://keybase.io/magrath) on keybase.
* I have a public key whose fingerprint is 4E1E 2273 E7C7 0882 93CE C585 8109 C2B4 373A A79F
To claim this, I am signing this object: