diff --git a/clean.py b/clean.py index 589d36f..aff9547 100755 --- a/clean.py +++ b/clean.py @@ -55,9 +55,10 @@ def _simple_delete(self, describe_function, delete_function, preserve_key, list_ self._delete_generic_resource(deletables, list_key, delete_function, item_key) def run_safety_checks(self, sts, iam, iam_resource): - # AWS Account ID in config.yml must match the account we are accessing using an API key + # AWS Account ID in config.yml must match the account we are accessing using an API key (if null then use only account_aliases) account_id = sts.get_caller_identity().get("Account") - assert account_id == self.config.get("assertions").get("account_id"), "Unexpected AWS Account ID, check configuration!" + if self.config.get("assertions").get("account_id"): + assert account_id == self.config.get("assertions").get("account_id"), "Unexpected AWS Account ID, check configuration!" # AWS Account alias in config.yml must match the account alias account_aliases = iam.list_account_aliases().get("AccountAliases") @@ -174,3 +175,5 @@ def get_boto_session(profile_name): cleaner.delete_securitygroups(ec2) cleaner.delete_key_pairs(ec2) cleaner.delete_buckets(s3, s3_resource) + +