-
Notifications
You must be signed in to change notification settings - Fork 0
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
🌐 Print "Empty" Route53 Hosted Zones #49
Conversation
🦙 MegaLinter status: ✅ SUCCESS
See detailed report in MegaLinter reports |
This will allows one and all to run the action using the click of a button.
print("The following hosted zones are empty:") | ||
for zone in empty_zones: | ||
print(f" - {zone}") | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should exit with an error here? 🤔 The program has been completed successfully at this point and printed empty hosted zones ✅
Seeing the CI/CD go red may lead to some wild goose chases for a problem that doesn't exist 🪿
sys.exit(1) |
sys.exit(1) | ||
else: | ||
print("No empty hosted zones found.") | ||
sys.exit(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think we can remove this since it's implied there were no errors if we don't raise any errors? 👀
sys.exit(0) |
def get_aws_zones(): | ||
route53 = boto3.client("route53") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend instantiating the Route53Client at the top level and passing it through to these functions 🤝
Mainly because it shows at a high level what the external dependencies the script requires - and also what dependencies each functions require 🥂
Can imagine reading this function get_aws_zones()
and thinking it could be reading from an S3Bucket, using a local variable or reading from a local file - but get_aws_zones(route53Client)
is a bit clearer where the information is coming from 👀
Also makes testing a bit easier 🧪
@pytest.fixture | ||
def mock_boto3_client(): | ||
with patch('boto3.client') as mock_client: | ||
yield mock_client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like a good method to use for testing at scale 🚀
I believe sticking with the explicit patches on each test is more readable in this case 👀 But maybe I'm stuck in my ways 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Looks Good To Me! - just a few comments 💬
👀 Purpose
♻️ What's changed
📝 Notes