Skip to content

aherve/iamsigned

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IAM signed

Provides helpers to send IAM-signed requests to AWS AppSync and AWS API Gateway services

  • Generates a v4 sign using IAM credentials
  • Properly sends the request to the aws service
  • Checks for http status error code
  • Parses graphQL response and checks for graphql-formatted errors (Appsync only)

Example Usage (Appsync GraphQL)

package main

import (
	"log"

	"github.com/aherve/iamsigned"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
)

var endpoint = "https://xxx.appsync-api.eu-west-1.amazonaws.com/graphql"
var region = "eu-west-1"

var myMutation = `
{
	"Query": "mutation(...)",
	"Variables": {...},
}
`

func main() {
	sess, err := session.NewSession(&aws.Config{Region: aws.String(region)})
	if err != nil {
		log.Fatal(err)
	}

	resp, err := iamsigned.AppSync([]byte(myMutation), endpoint, region, sess.Config.Credentials)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("SUCCESS : %s", string(resp))
}

About

Send IAM-signed requests to AppSync and API Gateway

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages