Skip to content

Instantly share code, notes, and snippets.

View macbutch's full-sized avatar

Mark Butcher macbutch

View GitHub Profile
@macbutch
macbutch / appsync.js
Last active July 20, 2018 13:09
AppSync Certificate Auth
const AppSyncClient = (credentials) => {
return new AWSAppSyncClient({
url: APPSYNC_ENDPOINT,
region: APPSYNC_REGION,
auth: {
type: 'AWS_IAM',
credentials: credentials
},
disableOffline: true
@macbutch
macbutch / AWS Certificate Auth
Last active July 20, 2018 13:00
AWS IoT Authentication
import AWS from 'aws-sdk'
import { AWSAppSyncClient } from 'aws-appsync'
const AwsCredentials = () => {
return new Promise((resolve, reject) => {
const options = {
httpOptions: {
key: fs.readFileSync('./privateKey'),
cert: fs.readFileSync('./certificate'),
ca: [
"dependencies": {
"apollo-cache-inmemory": "^1.1.0",
"apollo-client": "^2.0.3",
"apollo-link": "^1.0.3",
"apollo-link-http": "^1.2.0",
"aws-appsync": "^1.0.23",
"aws-iot-device-sdk": "^2.2.1",
"aws-sdk": "^2.273.1",
"binary-parser": "^1.3.2",
"concentrate": "^0.2.3",
@macbutch
macbutch / main.tf
Created June 19, 2018 03:01
IoT Policy for Assuming Credentials
resource "aws_iot_policy" "thing_policy" {
name = "iot-thing-policy"
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "iot:AssumeRoleWithCertificate",
@macbutch
macbutch / main.tf
Last active May 2, 2019 01:40
Terraform IoT Credential Policies
resource "aws_iam_role" "iot_access" {
name = "iot-access"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": {"Service": "credentials.iot.amazonaws.com"},
"Action": "sts:AssumeRole"

Keybase proof

I hereby claim:

  • I am macbutch on github.
  • I am markbutcher (https://keybase.io/markbutcher) on keybase.
  • I have a public key ASALFqSCCKL35QtMaZ916Lf8-vk0e_YePJQm81XeX_ylaQo

To claim this, I am signing this object: