我是 AWS 新手,第一次使用关系数据库服务(RDS)。
我已经从 AWS 控制台在 RDS 上创建了一个数据库(MySQL)。现在我尝试在数据库中创建一些表,并使用Golang SDK简单地插入和检索数据。我在 Golang 中创建了以下代码来运行 SQL 查询,但出现如下错误。
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/rdsdataservice"
)
func main() {
// Initialize a session in us-east-2
sess, _ := session.NewSession(&aws.Config{
Region: aws.String("us-east-2")},
)
// Sending a request using the ExecuteStatementRequest method.
SQLStatement := `CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);`
// Create RDS service client
rdsdataservice_client := rdsdataservice.New(sess)
req, resp := rdsdataservice_client.ExecuteStatementRequest(&rdsdataservice.ExecuteStatementInput{
Database: aws.String("database-1"),
ResourceArn: aws.String("arn:aws:rds:us-east-2:9xxxxxxxx9:db:database-1"),
SecretArn: aws.String("arn:aws:secretsmanager:us-east-2:9xxxxxxxx9:secret:RDS_Credentials-IZOXv0"),
Sql: aws.String(SQLStatement),
})
err1 := req.Send()
if err1 == nil { // resp is now filled
fmt.Println("Response:", resp)
} else {
fmt.Println("error:", err1)
}
}
我遇到以下错误 -
BadRequestException: Invalid cluster arn: arn:aws:rds:us-east-2:9xxxxxxxx9:db:database-1
status code: 400, request id: a7744d7c-4f19-232f-8bf1-c25662968d55
如果有人能帮助我找到问题,我将不胜感激。
相关分类