I'm writing an AWS lambda function to take my most recent snapshot of our production database and restore it as a new DB. This worked fine as a RDS instance but we recently switched our main DB to Aurora and its a cluster not an instance.
I looked in the API and was able to repurpose the old logic. I swapped out the word instance
for cluster
for the most part and it looked to work, it created a new cluster, etc. The new cluster however is showing 0 instances, whereas the DB it originated from shows 1. I think this is preventing me from remote connecting to it like I can the original DB cluster.
I'm still really not sure what a cluster is but do I have to launch an instance separately to enable remote connection?
Here is part of the python script btw -
def byTimestamp(snap):
if 'SnapshotCreateTime' in snap:
return datetime.datetime.isoformat(snap['SnapshotCreateTime'])
else:
return datetime.datetime.isoformat(datetime.datetime.now())
def restore_db():
client = boto3.client('rds', region_name=region)
source_snaps = client.describe_db_cluster_snapshots(DBClusterIdentifier = 'main-production')['DBClusterSnapshots']
source_snap = sorted(source_snaps, key=byTimestamp, reverse=True)[0]['DBClusterSnapshotIdentifier']
response = client.restore_db_cluster_from_snapshot(
DBClusterIdentifier='main-development',
SnapshotIdentifier=source_snap,
Port=port,
Engine='aurora-postgresql')