(ctx context.Context, conf db.ConnectionConfig)
| 228 | } |
| 229 | |
| 230 | func 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 | // |
no test coverage detected