Skip to content

Making account_id not required (account_aliases still required). #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)