Documentation
¶
Overview ¶
Package rdsmysql is a MySQL SQL driver that allows IAM Database Authentication for Amazon RDS and IAM Database Authentication for Amazon Aurora. It also supports connecting with the RDS proxy using IAM authentication.
Index ¶
Examples ¶
Constants ¶
View Source
const Certificates = rdsCertificates
Certificates is the certificates for connecting RDS MySQL with SSL/TLS. It contains the intermediate and root certificates for Amazon RDS MySQL and Amazon Aurora MySQL.
Variables ¶
View Source
var TLSConfig *tls.Config
TLSConfig is the tls.TLSConfig for connecting RDS MySQL with SSL/TLS.
Functions ¶
Types ¶
type Connector ¶
type Connector struct {
// Session is AWS Session.
Session *session.Session
// Config is a configure for connecting to MySQL servers.
Config *mysql.Config
// MaxConnsPerSecond is a limit for creating new connections.
// Zero means no limit.
MaxConnsPerSecond int
// contains filtered or unexported fields
}
Connector is a MySQL connector using IAM DB Auth. It implements database/sql/driver.Connector.
Example ¶
package main
import (
"database/sql"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/go-sql-driver/mysql"
"github.com/shogo82148/rdsmysql"
)
func main() {
// configure AWS session
awsConfig := aws.NewConfig().WithRegion("ap-northeast-1")
awsSession := session.Must(session.NewSession(awsConfig))
// configure the connector
cfg, err := mysql.ParseDSN("user:@tcp(db-foobar.ap-northeast-1.rds.amazonaws.com:3306)/")
if err != nil {
panic(err)
}
connector := &rdsmysql.Connector{
Session: awsSession,
Config: cfg,
}
// open the database
db := sql.OpenDB(connector)
defer db.Close()
// ... do something using db ...
}
Output:
type Driver ¶
Driver is a MySQL driver using IAM DB Auth.
Example ¶
package main
import (
"database/sql"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/shogo82148/rdsmysql"
)
func main() {
// register authentication information
awsConfig := aws.NewConfig().WithRegion("ap-northeast-1")
awsSession := session.Must(session.NewSession(awsConfig))
driver := &rdsmysql.Driver{
Session: awsSession,
}
sql.Register("rdsmysql", driver)
db, err := sql.Open("rdsmysql", "user:@tcp(db-foobar.ap-northeast-1.rds.amazonaws.com:3306)/")
if err != nil {
panic(err)
}
defer db.Close()
// ... do something using db ...
}
Output:
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
rdsmysql
command
|
|
|
rdsmysqldump
command
|
|
|
internal
|
|
|
cmd/update_certificate
command
|
|
Click to show internal directories.
Click to hide internal directories.