Skip to content
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

feat(aws): Add new RDS check to ensure db clusters are configured for multiple availability zones #4781

Conversation

danibarranqueroo
Copy link
Member

Context

This new check verifies that Amazon RDS DB clusters are configured to operate across multiple Availability Zones (AZs), enhancing high availability and resilience.

Since the Multi-AZ attribute is heritable from clusters to instances, I've modified the instance check to only scan instances that are not part of a cluster. Instances that are clustered are already covered by this new check.

For testing, while Moto supports the creation of instances with MultiAZ, it does not support MultiAZ on clusters. Therefore, I've had to use MagicMock for the cluster tests.

Description

I added rds_cluster_multi_az with its respective unit test and modified rds_instance_multi_azand its respective unit test.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@danibarranqueroo danibarranqueroo requested review from a team as code owners August 19, 2024 09:56
@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label Aug 19, 2024
Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.06%. Comparing base (0fcf424) to head (bd49e25).
Report is 24 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4781      +/-   ##
==========================================
- Coverage   89.13%   89.06%   -0.08%     
==========================================
  Files         921      927       +6     
  Lines       28157    28383     +226     
==========================================
+ Hits        25099    25278     +179     
- Misses       3058     3105      +47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

class rds_cluster_multi_az(Check):
def execute(self):
findings = []
for db_cluster in rds_client.db_clusters:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To iterate over a dict in Python I recommend you to use items() it will retrieve the key and the value in the same iteration.

Suggested change
for db_cluster in rds_client.db_clusters:
for db_cluster_arn, db_cluster in rds_client.db_clusters.items():

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your advice! 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, revert this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, revert this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, revert this.

Copy link
Member

@MrCloudSec MrCloudSec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, revert the changes in the instances checks since we want all the resources to appear in the check.

Copy link
Member

@MrCloudSec MrCloudSec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏼

@MrCloudSec MrCloudSec merged commit 0005f86 into prowler-cloud:master Aug 22, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/aws Issues/PRs related with the AWS provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants