This is an English translation of a Japanese blog. Some content may not be fully translated.
AWS

Creating Aurora PostgreSQL with AWS CLI

The flow appears to be create-db-clustercreate-db-instance. Since it cannot be done in a single command, multiple executions are required.

Creating a Cluster

aws rds create-db-cluster \
    --db-cluster-identifier        aurorapgsqlv1-cluster1 \
    --engine                       aurora-postgresql \
    --engine-version               11.9 \
    --master-username              postgres \
    --master-user-password         postgres \
    --db-subnet-group-name         devvpc-db-sub-pvt \
    --vpc-security-group-ids       sg-01f24d968d81d144a \
    --availability-zones           "ap-northeast-1a" "ap-northeast-1c" "ap-northeast-1d" \
    --port                         5432 \
    --database-name                postgres

create-db-cluster — AWS CLI 1.20.3 Command Reference https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-cluster.html

Creating an Instance

aws rds create-db-instance \
    --db-instance-identifier       aurorapgsqlv1-instance1 \
    --db-instance-class            db.r5.large \
    --engine                       aurora-postgresql \
    --engine-version               11.9 \
    --availability-zone            "ap-northeast-1c"  \
    --db-cluster-identifier        aurorapgsqlv1-cluster1 \
    --db-parameter-group-name      aurora-pgsql11

To create a read replica, run the same command again:

aws rds create-db-instance \
    --db-instance-identifier       aurorapgsqlv1-instance2 \
    --db-instance-class            db.r5.large \
    --engine                       aurora-postgresql \
    --engine-version               11.9 \
    --availability-zone            "ap-northeast-1d" \
    --db-cluster-identifier        aurorapgsqlv1-cluster1 \
    --db-parameter-group-name      aurora-pgsql11

create-db-instance — AWS CLI 1.20.3 Command Reference https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-instance.html

Result

As shown below, it was confirmed from the management console as well.

image-20210721234314409

Suggest an edit on GitHub