Skip to content

Commit

Permalink
Fixed RDS Snapshot remove public access remediation job (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshrutik authored Jan 31, 2022
1 parent 9ae113f commit aac016e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def remediate(self, client, snapshot_identifier):
# is shared publicly
logging.info("executing client.describe_db_snapshot_attributes")
logging.info(f"RDS instance={snapshot_identifier}")
snapshot_attrs_result = client.describe_db_snapshot_attributes(DBInstanceIdentifier=snapshot_identifier).get('DBSnapshotAttributesResult')
snapshot_attrs_result = client.describe_db_snapshot_attributes(DBSnapshotIdentifier=snapshot_identifier).get('DBSnapshotAttributesResult')
snapshot_attrs = snapshot_attrs_result.get("DBSnapshotAttributes")
snapshot_restore_attr = next(snapshot_attr for snapshot_attr in snapshot_attrs if snapshot_attr["AttributeName"] == "restore")
is_public = True if "all" in snapshot_restore_attr["AttributeValues"] else False
Expand All @@ -92,7 +92,7 @@ def remediate(self, client, snapshot_identifier):
logging.info("executing client.modify_db_snapshot_attribute and apply immediately")
logging.info("Attribute=Restore,Remove all AttributeValue")
client.modify_db_snapshot_attribute(
DBInstanceIdentifier=snapshot_identifier,
DBSnapshotIdentifier=snapshot_identifier,
AttributeName="restore",ValuesToRemove=["all"]
)
logging.info(
Expand Down

0 comments on commit aac016e

Please sign in to comment.