From 1fd2e36049f14bf42899f69f7e08935e687a8f60 Mon Sep 17 00:00:00 2001 From: Chinedu Obiakara Date: Fri, 19 Nov 2021 12:00:15 -0600 Subject: [PATCH] fixed code to handle all regions and formatted output --- checks/check_extra7162 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/checks/check_extra7162 b/checks/check_extra7162 index 782f4c1bf1..21c3443062 100644 --- a/checks/check_extra7162 +++ b/checks/check_extra7162 @@ -26,17 +26,24 @@ CHECK_CAF_EPIC_extra7162='Data Retention' extra7162() { # "Check if Log Groups have retention Policy of 356 days" for regx in $REGIONS; do - LIST_OF_365_RETENTION_LOG_GROUPS=$($AWSCLI logs describe-log-groups $PROFILE_OPT --region $regx --query 'logGroups[?retentionInDays==`365`].[logGroupName]' --output text)) + LIST_OF_365_RETENTION_LOG_GROUPS=$($AWSCLI logs describe-log-groups $PROFILE_OPT --region $regx --query 'logGroups[?retentionInDays==`365`].[logGroupName]' --output text) if [[ $LIST_OF_365_RETENTION_LOG_GROUPS ]]; then for log in $LIST_OF_365_RETENTION_LOG_GROUPS; do - textPass "$regx: $log has 365 days retention period!" "$regx" "$log" + textPass "$regx: $log Log Group has 365 days retention period!" "$regx" "$log" done fi - LIST_OF_NON_365_RETENTION_LOG_GROUPS=$($AWSCLI logs describe-log-groups $PROFILE_OPT --region $regx --query 'logGroups[?retentionInDays!=`365`].[logGroupName]' --output text)) + LIST_OF_NON_365_RETENTION_LOG_GROUPS=$($AWSCLI logs describe-log-groups $PROFILE_OPT --region $regx --query 'logGroups[?retentionInDays!=`365`].[logGroupName]' --output text) if [[ $LIST_OF_NON_365_RETENTION_LOG_GROUPS ]]; then for log in $LIST_OF_NON_365_RETENTION_LOG_GROUPS; do - textFail "$regx: $log does not have 365 days retention period!" "$regx" "$log" + textFail "$regx: $log Log Group does not have 365 days retention period!" "$regx" "$log" done fi + REGION_NO_LOG_GROUP=$($AWSCLI logs describe-log-groups $PROFILE_OPT --region $regx --output text) + if [[ $REGION_NO_LOG_GROUP ]]; then + : + else + textInfo "$regx does not have a Log Group!" "$regx" + + fi done }