Code Monkey home page Code Monkey logo

dynamodb-examples's People

Contributors

markuscraig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dynamodb-examples's Issues

ERROR: NoCredentialProviders: no valid providers in chain

Hey, thanks for these examples but I am having a problem when running dynamo in docker

ERROR: NoCredentialProviders: no valid providers in chain
caused by: EnvAccessKeyNotFound: failed to find credentials in the environment.
SharedCredsLoad: failed to load profile, .
EC2RoleRequestError: no EC2 instance role found
caused by: RequestError: send request failed
caused by: Get http://169.254.169.254/latest/meta-data/iam/security-credentials/: dial tcp 169.254.169.254:80: connect: connection refused

It looks as though the go sdk is looking for some credentials in ~/.aws/credentials. Is there a way I can bypass this? Since I do not require my code to actually speak to AWS but rather a docker container containing the dynamodb image.

How do you recommend that one sets up these examples within docker?

Any help is greatly appreciated.

My code looks like;

func main() {
	fmt.Println("running...")
	t := true
	// create an aws session
	sess := session.Must(session.NewSession(&aws.Config{
		CredentialsChainVerboseErrors: &t,
		Region:   aws.String("us-east-1"),
		Endpoint: aws.String("dynamodb-app:8000"),
		//EndPoint: aws.String("https://dynamodb.us-east-1.amazonaws.com"),
	}))
	fmt.Println("A")
	// create a dynamodb instance
	db := dynamodb.New(sess)

	// movie data
	movie := types.Movie{
		Year:  2015,
		Title: "The Big New Movie",
		Info: types.MovieInfo{
			Plot:   "Nothing happens at all.",
			Rating: 1.1,
		},
	}
	fmt.Println("B")
	// marshal the movie struct into an aws attribute value
	movieAVMap, err := dynamodbattribute.MarshalMap(movie)
	if err != nil {
		panic("Cannot marshal movie into AttributeValue map")
	}
	fmt.Println("C")
	// create the api params
	params := &dynamodb.PutItemInput{
		TableName: aws.String("Movies"),
		Item:      movieAVMap,
	}

	// put the item
	resp, err := db.PutItem(params)
	if err != nil {
		fmt.Printf("ERROR: %v\n", err.Error())
		return
	}

	// print the response data
	fmt.Println("Success")
	fmt.Println(resp)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.