-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(elasticache): Ensure Redis replication groups have automatic failover enabled #4853
feat(elasticache): Ensure Redis replication groups have automatic failover enabled #4853
Conversation
…o PRWLR-4508-elasti-cache-redis-oss-replication-groups-should-have-automatic-failover-enabled
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4853 +/- ##
==========================================
- Coverage 89.20% 88.93% -0.28%
==========================================
Files 933 954 +21
Lines 28567 29256 +689
==========================================
+ Hits 25483 26018 +535
- Misses 3084 3238 +154
|
auto_minor_version_upgrade: bool = False | ||
automatic_failover: Optional[str] = None |
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.
You are already setting a default value when creating the model inside the function.
auto_minor_version_upgrade: bool = False | |
automatic_failover: Optional[str] = None | |
auto_minor_version_upgrade: bool | |
automatic_failover: str |
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.
If I don't set the default value here, several tests for this and other checks will fail as a result. This occurs because when we mock them, the value is never assigned.
Should I leave it as it was, or should I update every mock instance across all checks?
@@ -106,6 +106,9 @@ def _describe_replication_groups(self, regional_client): | |||
auto_minor_version_upgrade=repl_group.get( | |||
"AutoMinorVersionUpgrade", False | |||
), | |||
automatic_failover=repl_group.get( | |||
"AutomaticFailover", None |
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.
We always set the non-compliant value as the default.
"AutomaticFailover", None | |
"AutomaticFailover", "disabled" |
@@ -192,4 +192,5 @@ def test_describe_replication_groups(self): | |||
multi_az=REPLICATION_GROUP_MULTI_AZ, | |||
tags=REPLICATION_GROUP_TAGS, | |||
auto_minor_version_upgrade=AUTO_MINOR_VERSION_UPGRADE, | |||
automatic_failover=None, |
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.
automatic_failover=None, | |
automatic_failover="disabled", |
...utomatic_failover_enabled/elasticache_redis_cluster_automatic_failover_enabled.metadata.json
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,32 @@ | |||
{ | |||
"Provider": "aws", | |||
"CheckID": "elasticache_redis_cluster_automatic_failover_enabled", |
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 think we should now something more like: elasticache_replication_group_redis_has_automatic_failover
"SubServiceName": "", | ||
"ResourceIdTemplate": "arn:partition:service:region:account-id:resource-id", | ||
"Severity": "medium", | ||
"ResourceType": "AWSElastiCacheClusters", |
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 think this ResourceType is not supported by AWS, please refer to the docs
report.resource_arn = repl_group.arn | ||
report.resource_tags = repl_group.tags | ||
report.status = "FAIL" | ||
report.status_extended = f"Elasticache Redis cache cluster {repl_group.id} does not have automatic failover enabled." |
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.
report.status_extended = f"Elasticache Redis cache cluster {repl_group.id} does not have automatic failover enabled." | |
report.status_extended = f"ElastiCache Redis replication group {repl_group.id} does not have automatic failover enabled." |
assert result[0].status == "PASS" | ||
assert ( | ||
result[0].status_extended | ||
== f"Elasticache Redis cache cluster {REPLICATION_GROUP_ID} does have automatic failover enabled." |
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.
Change this according to new changes in the checks
..._automatic_failover/elasticache_redis_replication_group_has_automatic_failover.metadata.json
Outdated
Show resolved
Hide resolved
}, | ||
"Recommendation": { | ||
"Text": "Enable automatic failover for ElastiCache (Redis OSS) clusters to ensure high availability and minimize downtime during failures.", | ||
"Url": "https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.Modify.html#Clusters.Modify.CON" |
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 think this link is not working as expected, the tags at the end are not doing anything. And I cannot see the Automatic Failover recommendation. Please, review it.
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.
LGTM!
Context
A check was done to ensure ElastiCache (Redis OSS) replication groups have automatic failover enabled for high availability.
Description
I added a new check
elasticache_redis_cluster_automatic_failover_enabled
that ensures Elasticache Redis OSS cache clusters use automatic failover to maximize high availability and minimize downtime during failures.Checklist
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.