Skip to content

Commit

Permalink
Update snapshot functions to python3
Browse files Browse the repository at this point in the history
  • Loading branch information
minniux committed May 7, 2021
1 parent 9739208 commit d52b34e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions snapshot-replicator/functions/remove_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def deleteSnapshots(region):
for snapshot in snapshots:
create_ts = snapshot['SnapshotCreateTime'].replace(tzinfo=None)
if create_ts < datetime.datetime.now() - datetime.timedelta(days=int(duration)):
print("Deleting snapshot id:", snapshot['DBSnapshotIdentifier'])
print(("Deleting snapshot id:", snapshot['DBSnapshotIdentifier']))
try:
response = rds.delete_db_snapshot(DBSnapshotIdentifier=snapshot['DBSnapshotIdentifier'])
print response
print(response)
except botocore.exceptions.ClientError as e:
raise Exception("Could not issue delete command: %s" % e)

Expand Down
2 changes: 1 addition & 1 deletion snapshot-replicator/functions/shipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def lambda_handler(event, context):
source_snap_arn = snapshot_details['DBSnapshotArn']
target_snap_id = (re.sub('rds:', '', source_snap))
target = boto3.client('rds', region_name=target_region)
print('Will Copy %s to %s' % (source_snap_arn, target_snap_id))
print(('Will Copy %s to %s' % (source_snap_arn, target_snap_id)))
try:
response = target.copy_db_snapshot(
SourceDBSnapshotIdentifier=source_snap_arn,
Expand Down
6 changes: 3 additions & 3 deletions snapshot-replicator/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ resource "aws_lambda_function" "rds_snapshot_copy" {
filename = data.archive_file.create_zip.output_path
source_code_hash = data.archive_file.create_zip.output_base64sha256

runtime = "python2.7"
runtime = "python3.8"
timeout = "120"

environment {
Expand All @@ -184,7 +184,7 @@ resource "aws_lambda_function" "rds_snapshot_create" {
filename = data.archive_file.create_zip.output_path
source_code_hash = data.archive_file.create_zip.output_base64sha256

runtime = "python2.7"
runtime = "python3.8"
timeout = "120"

environment {
Expand All @@ -206,7 +206,7 @@ resource "aws_lambda_function" "rds_snapshot_cleanup" {
filename = data.archive_file.create_zip.output_path
source_code_hash = data.archive_file.create_zip.output_base64sha256

runtime = "python2.7"
runtime = "python3.8"
timeout = "120"

environment {
Expand Down

0 comments on commit d52b34e

Please sign in to comment.