From 7b4cc3b61a8b69fcb5446cc42c890bd11fe05a00 Mon Sep 17 00:00:00 2001 From: Gustavo Aguiar Date: Mon, 28 May 2018 12:53:00 -0400 Subject: [PATCH] Making account_id not required (account_aliases still required). --- clean.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) + +