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

Function getRDSConnectionPassword

backend/plugin/db/pg/pg.go:230–249  ·  view source on GitHub ↗
(ctx context.Context, conf db.ConnectionConfig)

Source from the content-addressed store, hash-verified

228}
229
230func getRDSConnectionPassword(ctx context.Context, conf db.ConnectionConfig) (string, error) {
231 cfg, err := util.GetAWSConnectionConfig(ctx, conf)
232 if err != nil {
233 return "", errors.Wrap(err, "load aws config failed")
234 }
235
236 // Handle cross-account role assumption if configured
237 if err := util.AssumeRoleIfNeeded(ctx, &cfg, conf.ConnectionContext, conf.DataSource.GetAwsCredential()); err != nil {
238 return "", err
239 }
240
241 dbEndpoint := fmt.Sprintf("%s:%s", conf.DataSource.Host, conf.DataSource.Port)
242 authenticationToken, err := auth.BuildAuthToken(
243 ctx, dbEndpoint, conf.DataSource.GetRegion(), conf.DataSource.Username, cfg.Credentials)
244 if err != nil {
245 return "", errors.Wrap(err, "failed to create authentication token")
246 }
247
248 return authenticationToken, nil
249}
250
251// getRDSConnectionConfig returns connection config for AWS RDS.
252//

Callers 1

getRDSConnectionConfigFunction · 0.85

Calls 5

GetAWSConnectionConfigFunction · 0.92
AssumeRoleIfNeededFunction · 0.92
BuildAuthTokenMethod · 0.65
GetAwsCredentialMethod · 0.45
GetRegionMethod · 0.45

Tested by

no test coverage detected