markuscraig / dynamodb-examples Goto Github PK
View Code? Open in Web Editor NEWExamples of accessing DynamoDB using the AWS SDK in Golang and Node.js
Examples of accessing DynamoDB using the AWS SDK in Golang and Node.js
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)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.