File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
src/rpdk/guard_rail/utils Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -181,23 +181,27 @@ def _add_tagging_key(schema: Dict):
181
181
182
182
if tags_schema .get ("type" ) == "object" :
183
183
184
- def _get_first_pattern_key (schema : Dict ) -> str :
184
+ def _get_all_pattern_key (schema : Dict ) -> str :
185
185
pattern_properties = schema .get ("patternProperties" , {})
186
186
if pattern_properties :
187
- return next ( iter ( pattern_properties ))
188
- return None
187
+ return list ( pattern_properties . keys ( ))
188
+ return []
189
189
190
190
if "patternProperties" in tags_schema :
191
- tag_key = {"pattern" : _get_first_pattern_key (tags_schema )}
191
+ tag_key = {"pattern" : _get_all_pattern_key (tags_schema )}
192
192
schema ["TaggingKeyPattern" ] = _is_tag_key_pattern_match (tag_key )
193
193
return
194
194
195
195
196
- def _is_tag_key_pattern_match (tag_key : str ) :
196
+ def _is_tag_key_pattern_match (tag_key : Dict ) -> bool :
197
197
_AWS_PREFIX_TAG = "aws:"
198
+
198
199
if "pattern" in tag_key :
199
200
tag_key_pattern = tag_key ["pattern" ]
200
201
if isinstance (tag_key_pattern , str ):
201
- is_blocked = not re .match (tag_key_pattern , _AWS_PREFIX_TAG )
202
- return is_blocked
202
+ return not re .match (tag_key_pattern , _AWS_PREFIX_TAG )
203
+ if isinstance (tag_key_pattern , list ):
204
+ return all (
205
+ not re .match (pattern , _AWS_PREFIX_TAG ) for pattern in tag_key_pattern
206
+ )
203
207
return False
You can’t perform that action at this time.
0 commit comments