Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

cnry/aws-sdk-go-wrapper

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status (checked SDK version aws-sdk-go :: v0.6.6

Coverage Status

aws-sdk-go-wrapper

Simple wrapper for aws-sdk-go At this time, it suports services below,

  • DynamoDB
  • S3
  • SQS
  • SNS

Configure

vim aws.json

{
    "access_key": "XXXXXXXXXXXXXXXXXXXX",
    "secret_key": "abcdefg",
}

Quick Usage

DynamoDB

import (
    "github.com/cnry/aws-sdk-go-wrapper/dynamodb"
)

func main() {
    // Create connection client
    cli := ddb.NewClient()

    // Get dynamodb table
    table, err := cli.GetTable("MyDynamoTable")
    if err != nil {
        panic("error on loading dynamodb table")
    }

    // Create new dynamodb item (row on RDBMS)
    item := dynamodb.NewItem()
    item.AddAttribute("user_id", 999)
    item.AddAttribute("status", 1)

    // Add item to the wait list.
    table.AddItem(item)

    item2 := dynamodb.NewItem()
    item.AddAttribute("user_id", 1000)
    item.AddAttribute("status", 2)
    item.AddConditionEQ("status", 3) // Add condition for write
    table.AddItem(item2)

    // write all
    cli.PutAll()
}

S3

import(
    "os"

    // import this
    "github.com/cnry/aws-sdk-go-wrapper/s3"
)

func main(){
    cli := s3.NewClient()
    bucket := cli.GetBucket("MyBucket")

    // upload file
    var file *os.File
    file = getFile() // dummy code. this expects return data of "*os.File", like from POST form.
    s3obj := s3.NewS3Object(file)
    bucket.AddObject(s3obj, "/foo/bar/new_file")
    bucket.Put()

    // upload file from text data
    text := "Lorem ipsum"
    s3obj2 := s3.NewS3ObjectString(text)
    bucket.AddObject(s3obj2, "/log/new_text.txt")

    // upload file of ACL authenticated-read
    bucket.AddSecretObject(s3obj2, "/secret_path/new_secret_file.txt")


    // put all added objects.
    bucket.Put() // upload "/log/new_text.txt" & "/secret_path/new_secret_file.txt"
}

License

Apache License, Version 2.0

About

Simple wrapper for aws-sdk-go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 98.8%
  • Ruby 1.2%