如何克服 ResourceNotFoundException: Requested resource not found 错误?
How to overcome ResourceNotFoundException: Requested resource not found error in Go lang?
我是 Go lang 的初学者,我正在尝试使用 AWS 在 Go lang 和 Dynamodb 之间建立连接,并使用用 Go lang 编写的 API 在 dynamodb 中插入数据。任何帮助,将不胜感激。
下面是我正在尝试做的代码:
package main
import "fmt"
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/user/dynamo_connect/data"
)
func database_init() {
var testCredentials = credentials.NewStaticCredentials("Access_key", "secret_key", "")
sess, err := session.NewSession()
svc := dynamodb.New(sess, &aws.Config{
Region: aws.String("us-east-1"),
Credentials: testCredentials,
})
resp, err := data.UploadForumData(svc)
if err != nil {
fmt.Println("An error occurred while writing to the Employee table")
fmt.Println(err.Error())
}
fmt.Println(resp)
}
func main() {
database_init()
}
package data
import "github.com/aws/aws-sdk-go/service/dynamodb"
import "github.com/aws/aws-sdk-go/aws"
func UploadForumData(svc *dynamodb.DynamoDB) (*dynamodb.BatchWriteItemOutput, error) {
params := &dynamodb.BatchWriteItemInput{
RequestItems: map[string][]*dynamodb.WriteRequest{
"employee": {
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"emp_id": {
S: aws.String("2"),
},
"address": {
S: aws.String("Wing Apartment"),
},
"emp_name": {
S: aws.String("Kaushal"),
},
},
},
},
},
},
}
return svc.BatchWriteItem(params)
}
这是我得到的错误:
An error occurred while writing to the Employee table
ResourceNotFoundException: Requested resource not found
status code: 400, request id: VIMB3ATCI6KPSJF1OOH2Q4VLKNVV4KQNSO5AEMVJF66Q9ASUAAJG
{
}
有人可以帮忙吗?
实际上,我的数据库有问题connectivity.The我输入的区域名称不正确。我已经使用 aws configure 命令重新检查并使其正常工作。
我是 Go lang 的初学者,我正在尝试使用 AWS 在 Go lang 和 Dynamodb 之间建立连接,并使用用 Go lang 编写的 API 在 dynamodb 中插入数据。任何帮助,将不胜感激。
下面是我正在尝试做的代码:
package main
import "fmt"
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/user/dynamo_connect/data"
)
func database_init() {
var testCredentials = credentials.NewStaticCredentials("Access_key", "secret_key", "")
sess, err := session.NewSession()
svc := dynamodb.New(sess, &aws.Config{
Region: aws.String("us-east-1"),
Credentials: testCredentials,
})
resp, err := data.UploadForumData(svc)
if err != nil {
fmt.Println("An error occurred while writing to the Employee table")
fmt.Println(err.Error())
}
fmt.Println(resp)
}
func main() {
database_init()
}
package data
import "github.com/aws/aws-sdk-go/service/dynamodb"
import "github.com/aws/aws-sdk-go/aws"
func UploadForumData(svc *dynamodb.DynamoDB) (*dynamodb.BatchWriteItemOutput, error) {
params := &dynamodb.BatchWriteItemInput{
RequestItems: map[string][]*dynamodb.WriteRequest{
"employee": {
&dynamodb.WriteRequest{
PutRequest: &dynamodb.PutRequest{
Item: map[string]*dynamodb.AttributeValue{
"emp_id": {
S: aws.String("2"),
},
"address": {
S: aws.String("Wing Apartment"),
},
"emp_name": {
S: aws.String("Kaushal"),
},
},
},
},
},
},
}
return svc.BatchWriteItem(params)
}
这是我得到的错误:
An error occurred while writing to the Employee table
ResourceNotFoundException: Requested resource not found
status code: 400, request id: VIMB3ATCI6KPSJF1OOH2Q4VLKNVV4KQNSO5AEMVJF66Q9ASUAAJG
{
}
有人可以帮忙吗?
实际上,我的数据库有问题connectivity.The我输入的区域名称不正确。我已经使用 aws configure 命令重新检查并使其正常工作。