Based on my research, I've found that the only way to create using CLI an Aurora cluster with instances inside it from an existing snapshot is to follow these steps:
1) Create snapshot from existing cluster
2) Launch cluster from snapshot
3) Add instance into cluster
Thus, the commands I ran using the most-up-to-date AWS CLI version are these (along with the outputs):
aws rds create-db-cluster-snapshot \
--db-cluster-snapshot-identifier analytics-replica-db \
--db-cluster-identifier prodcluster
which outputs
{
"DBClusterSnapshot": {
"Engine": "aurora",
"SnapshotCreateTime": "2017-07-24T15:08:12.836Z",
"VpcId": "vpc-ID",
"DBClusterIdentifier": "cluster_name",
"DBClusterSnapshotArn": "arn:aws:rds:eu-west-1:aws_account:cluster-snapshot:analytics-replica-db",
"MasterUsername": "db_username",
"LicenseModel": "aurora",
"Status": "creating",
"PercentProgress": 0,
"DBClusterSnapshotIdentifier": "analytics-replica-db",
"IAMDatabaseAuthenticationEnabled": false,
"ClusterCreateTime": "2016-04-14T11:10:02.413Z",
"StorageEncrypted": false,
"AllocatedStorage": 1,
"EngineVersion": "5.6.10a",
"SnapshotType": "manual",
"AvailabilityZones": [
"eu-west-1a",
"eu-west-1b",
"eu-west-1c"
],
"Port": 0
}
}
After that, I create the cluster using this:
aws rds restore-db-cluster-from-snapshot \
--db-cluster-identifier analytics-replica-cluster \
--snapshot-identifier analytics-replica-db \
--engine aurora \
--port 3306 \
--db-subnet-group-name this_is_a_subnet_group \
--database-name this_is_the_database_name_equal_to_original_cluster_db \
--vpc-security-group-ids this_is_a_random_security_group \
--no-enable-iam-database-authentication
which outputs
{
"DBCluster": {
"MasterUsername": "this_is_the_same_username_as_the_one_on_original_db",
"ReaderEndpoint": "this_is_the_new_RDS_endpoint_of_cluster",
"ReadReplicaIdentifiers": [],
"VpcSecurityGroups": [
{
"Status": "active",
"VpcSecurityGroupId": "this_is_that_security_group"
}
],
"HostedZoneId": "Z29XKXDKYMONMX",
"Status": "creating",
"MultiAZ": false,
"PreferredBackupWindow": "23:50-00:20",
"DBSubnetGroup": "this_is_a_subnet_group",
"AllocatedStorage": 1,
"BackupRetentionPeriod": 10,
"PreferredMaintenanceWindow": "fri:03:34-fri:04:04",
"Engine": "aurora",
"Endpoint": "this_is_the_new_RDS_endpoint_of_reader",
"AssociatedRoles": [],
"IAMDatabaseAuthenticationEnabled": false,
"ClusterCreateTime": "2017-07-24T15:11:07.003Z",
"EngineVersion": "5.6.10a",
"DBClusterIdentifier": "analytics-replica-cluster",
"DbClusterResourceId": "cluster-resource_id",
"DBClusterMembers": [],
"DBClusterArn": "arn:aws:rds:eu-west-1:aws_account:cluster:analytics-replica-cluster",
"StorageEncrypted": false,
"DatabaseName": "this_is_the_database_name_equal_to_original_cluster_db",
"DBClusterParameterGroup": "default.aurora5.6",
"AvailabilityZones": [
"eu-west-1a",
"eu-west-1b",
"eu-west-1c"
],
"Port": 3306
}
}
And now, all I want to do is just run this
aws rds create-db-instance \
--db-name this_is_the_database_name_equal_to_original_cluster_db \
--db-instance-identifier analytics-replica-instance \
--db-instance-class "db.r3.large" \
--publicly-accessible \
--no-enable-iam-database-authentication \
--db-cluster-identifier analytics-replica-cluster \
--engine aurora
which outputs
An error occurred (InvalidParameterCombination) when calling the CreateDBInstance operation: The requested DB Instance will be a member of a DB Cluster. Set database name for the DB Cluster.
Can someone PLEASE tell me why does it hate me?
--db-name
because that is set on the cluster, not the instance. "The requested DB Instance will be a member of a DB Cluster. [You can only] Set [the] database name for the DB Cluster [not the instance]." – Michael - sqlbot--db-name
on the cluster – Marius Mitrofan