GetSourceInfo returns information about the source database.
(ctx context.Context)
| 510 | |
| 511 | // GetSourceInfo returns information about the source database. |
| 512 | func (r *RDSClient) GetSourceInfo(ctx context.Context) (string, error) { |
| 513 | if r.cfg.Source.Type == sourceTypeAuroraCluster { |
| 514 | resp, err := r.client.DescribeDBClusters(ctx, &rds.DescribeDBClustersInput{ |
| 515 | DBClusterIdentifier: aws.String(r.cfg.Source.Identifier), |
| 516 | }) |
| 517 | if err != nil { |
| 518 | return "", fmt.Errorf("failed to describe source cluster: %w", err) |
| 519 | } |
| 520 | |
| 521 | if len(resp.DBClusters) == 0 { |
| 522 | return "", fmt.Errorf("source cluster %q not found", r.cfg.Source.Identifier) |
| 523 | } |
| 524 | |
| 525 | cluster := resp.DBClusters[0] |
| 526 | |
| 527 | return fmt.Sprintf("Aurora cluster %s (engine: %s, version: %s)", |
| 528 | r.cfg.Source.Identifier, |
| 529 | aws.ToString(cluster.Engine), |
| 530 | aws.ToString(cluster.EngineVersion)), nil |
| 531 | } |
| 532 | |
| 533 | resp, err := r.client.DescribeDBInstances(ctx, &rds.DescribeDBInstancesInput{ |
| 534 | DBInstanceIdentifier: aws.String(r.cfg.Source.Identifier), |
| 535 | }) |
| 536 | if err != nil { |
| 537 | return "", fmt.Errorf("failed to describe source instance: %w", err) |
| 538 | } |
| 539 | |
| 540 | if len(resp.DBInstances) == 0 { |
| 541 | return "", fmt.Errorf("source instance %q not found", r.cfg.Source.Identifier) |
| 542 | } |
| 543 | |
| 544 | instance := resp.DBInstances[0] |
| 545 | |
| 546 | return fmt.Sprintf("RDS instance %s (engine: %s, version: %s)", |
| 547 | r.cfg.Source.Identifier, |
| 548 | aws.ToString(instance.Engine), |
| 549 | aws.ToString(instance.EngineVersion)), nil |
| 550 | } |