I am new to AWS and working on Relational Database Service(RDS) for the first time.
I have created a database(MySQL) on RDS from the AWS console. Now I am trying to create some tables in the database and to simply insert and retrieve data from it using Golang SDK. I have created the below code in Golang to run a SQL query, but I am getting an error as below.
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)
}
}
I am getting below error -
BadRequestException: Invalid cluster arn: arn:aws:rds:us-east-2:9xxxxxxxx9:db:database-1
status code: 400, request id: a7744d7c-4f19-232f-8bf1-c25662968d55
I will appreciate if anyone can help me to find the issue.
I am using the following API reference documentation - link. I doubt that these API's are only for Aurora database and not for others. Please correct me if I am wrong and suggest the correct API's references.