{Aurora}Aurora リードレプリカを使用した、RDS PostgreSQL DB インスタンスから Aurora PostgreSQL DB クラスターへのデータの移行

問題の Aurora PostgreSQL バージョンと互換性のある RDS for PostgreSQL インスタンスからのみレプリケートできます。
例えば、Aurora PostgreSQL バージョン 12.4 がサポートされている場合、
RDS for PostgreSQL DB インスタンスは、バージョン 12.2 以降で実行する必要があります。


-- テスト用 RDS PostgreSQL作成


aws rds create-db-instance \
--db-instance-identifier postgres01 \
--allocated-storage 20 \
--db-instance-class db.t3.micro \
--engine postgres \
--master-username postgres \
--master-user-password 'password' \
--no-multi-az \
--engine-version 12.2 \
--storage-type gp2 \
--no-publicly-accessible \
--no-enable-performance-insights


-- Aurora リードレプリカの作成

aws rds create-db-cluster \
--db-cluster-identifier cluster01 \
--engine aurora-postgresql \
--engine-version 12.4 \
--replication-source-identifier arn:aws:rds:ap-northeast-1:999999999999:db:postgres01


aws rds create-db-instance \
--db-instance-identifier cluster01-instance01 \
--db-cluster-identifier cluster01 \
--db-instance-class db.t3.medium \
--engine aurora-postgresql \
--no-auto-minor-version-upgrade

-- Aurora リードレプリカの昇格

aws rds promote-read-replica-db-cluster \
--db-cluster-identifier cluster01


-- クリーンアップ

-- RDSインスタンス削除
aws rds delete-db-instance \
--db-instance-identifier postgres01 \
--skip-final-snapshot


-- Auroraクラスタ削除

aws rds delete-db-instance \
--db-instance-identifier cluster01-instance01 \
--skip-final-snapshot

aws rds delete-db-cluster \
--db-cluster-identifier cluster01 \
--skip-final-snapshot