MCPcopy Create free account
hub / github.com/bytebase/bytebase / GetAWSConnectionConfig

Function GetAWSConnectionConfig

backend/plugin/db/util/connection.go:21–40  ·  view source on GitHub ↗
(ctx context.Context, connCfg db.ConnectionConfig)

Source from the content-addressed store, hash-verified

19)
20
21func GetAWSConnectionConfig(ctx context.Context, connCfg db.ConnectionConfig) (aws.Config, error) {
22 region := connCfg.DataSource.GetRegion()
23
24 // Only use static credentials if access key is provided
25 // If awsCredential exists but AccessKeyId is empty, fall back to default credential chain
26 // (EC2 instance role, env vars, etc.) for cross-account role assumption
27 if awsCredential := connCfg.DataSource.GetAwsCredential(); awsCredential != nil && awsCredential.AccessKeyId != "" {
28 return config.LoadDefaultConfig(ctx,
29 config.WithRegion(region),
30 config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
31 awsCredential.AccessKeyId,
32 awsCredential.SecretAccessKey,
33 awsCredential.SessionToken,
34 )),
35 )
36 }
37
38 // Use default credential chain when no static credentials provided
39 return config.LoadDefaultConfig(ctx, config.WithRegion(region))
40}
41
42func GetGCPConnectionConfig(ctx context.Context, connCfg db.ConnectionConfig) (*cloudsqlconn.Dialer, error) {
43 // WithIAMAuthN enables IAM database authentication.

Callers 4

OpenMethod · 0.92
getRDSConnectionMethod · 0.92
getRDSConnectionPasswordFunction · 0.92
openWithOpenSearchClientFunction · 0.92

Calls 2

GetRegionMethod · 0.45
GetAwsCredentialMethod · 0.45

Tested by

no test coverage detected