@@ -107,32 +107,39 @@ def same_resource_type(self, arn_in_database):
107107 if i != "" :
108108 non_empty_arn_format_list .append (i )
109109
110+ lower_resource_string = list (map (lambda x :x .lower (),split_resource_string_to_test ))
110111 for i in non_empty_arn_format_list :
111112 # if i.lower() in [x.lower() for x in split_resource_string_to_test]:
112- if i .lower () not in split_resource_string_to_test :
113+ if i .lower () not in lower_resource_string :
113114 return False
114115
115116 # 4c: See if the non-normalized fields match
116- # for i in range(len(arn_format_list)):
117- # # If the field is not normalized to empty string, then make sure the resource type segments match
118- # # So, using table/${TableName}/backup/${BackupName} as an example:
119- # # table should match, backup should match,
120- # # and length of the arn_format_list should be the same as split_resource_string_to_test
121- # # If all conditions match, then the ARN format is the same.
122- # if arn_format_list[i] != "":
123- # if arn_format_list[i] == split_resource_string_to_test[i]:
124- # pass
125- # elif split_resource_string_to_test[i] == "*":
126- # pass
127- # else:
128- # return False
117+ for i in range (len (arn_format_list )):
118+ # If the field is not normalized to empty string, then make sure the resource type segments match
119+ # So, using table/${TableName}/backup/${BackupName} as an example:
120+ # table should match, backup should match,
121+ # and length of the arn_format_list should be the same as split_resource_string_to_test
122+ # If all conditions match, then the ARN format is the same.
123+ if arn_format_list [i ] != "" :
124+ if arn_format_list [i ] == split_resource_string_to_test [i ]:
125+ pass
126+ elif split_resource_string_to_test [i ] == "*" :
127+ pass
128+ else :
129+ return False
129130
130131 # 4. Special type for S3 bucket objects and CodeCommit repos
131132 # Note: Each service can only have one of these, so these are definitely exceptions
132- exclusion_list = ["${ObjectName}" , "${RepositoryName}" , "${BucketName}" ]
133+ exclusion_list = ["${ObjectName}" , "${RepositoryName}" , "${BucketName}" , "table/${TableName}" ]
133134 resource_path_arn_in_database = elements [5 ]
134135 if resource_path_arn_in_database in exclusion_list :
135136 logger .debug ("Special type: %s" , resource_path_arn_in_database )
137+ # handling special case table/${TableName}
138+ if resource_string_arn_in_database == "table/${TableName}" :
139+ if len (self .resource_string .split ('/' )) == len (elements [5 ].split ('/' )):
140+ return True
141+ else :
142+ return False
136143 # If we've made it this far, then it is a special type
137144 # return True
138145 # Presence of / would mean it's an object in both so it matches
0 commit comments