@@ -82,43 +82,46 @@ def _resolve_getatt(
8282 yield err
8383 break
8484 else :
85- for attribute_name , _ , _ in validator .resolve_value (value [1 ]):
86- if all (
87- not (bool (re .fullmatch (each , attribute_name )))
88- for each in validator .context .resources [resource_name ].get_atts
89- ):
90- err = ValidationError (
91- (
92- f"{ attribute_name !r} is not one of "
93- f"{ validator .context .resources [resource_name ].get_atts !r} "
94- ),
95- validator = self .fn .py ,
96- path = deque ([self .fn .name , 1 ]),
97- )
98- if attribute_name != value [1 ]:
99- err .message = (
100- err .message + f" when { value [1 ]!r} is resolved"
85+ t = validator .context .resources [resource_name ].type
86+ for (
87+ regions ,
88+ schema ,
89+ ) in PROVIDER_SCHEMA_MANAGER .get_resource_schemas_by_regions (
90+ t , validator .context .regions
91+ ):
92+ region = regions [0 ]
93+ for attribute_name , _ , _ in validator .resolve_value (value [1 ]):
94+ if all (
95+ not (bool (re .fullmatch (each , attribute_name )))
96+ for each in validator .context .resources [
97+ resource_name
98+ ].get_atts (region )
99+ ):
100+ err = ValidationError (
101+ (
102+ f"{ attribute_name !r} is not one of "
103+ f"{ validator .context .resources [resource_name ].get_atts (region )!r} "
104+ f" in { regions !r} "
105+ ),
106+ validator = self .fn .py ,
107+ path = deque ([self .fn .name , 1 ]),
101108 )
102- yield err
103- continue
104-
105- evolved = validator .evolve (schema = s ) # type: ignore
106- evolved .validators = { # type: ignore
107- "type" : validator .validators .get ("type" ), # type: ignore
108- }
109-
110- getatts = validator .cfn .get_valid_getatts ()
111- t = validator .context .resources [resource_name ].type
112- pointer = getatts .match (
113- validator .context .regions [0 ], [resource_name , attribute_name ]
114- )
115-
116- for (
117- _ ,
118- schema ,
119- ) in PROVIDER_SCHEMA_MANAGER .get_resource_schemas_by_regions (
120- t , validator .context .regions
121- ):
109+ if attribute_name != value [1 ]:
110+ err .message = (
111+ err .message + f" when { value [1 ]!r} is resolved"
112+ )
113+ yield err
114+ continue
115+
116+ evolved = validator .evolve (schema = s ) # type: ignore
117+ evolved .validators = { # type: ignore
118+ "type" : validator .validators .get ("type" ), # type: ignore
119+ }
120+
121+ getatts = validator .cfn .get_valid_getatts ()
122+ t = validator .context .resources [resource_name ].type
123+ pointer = getatts .match (region , [resource_name , attribute_name ])
124+
122125 getatt_schema = schema .resolver .resolve_cfn_pointer (pointer )
123126 if not getatt_schema .get ("type" ) or not s .get ("type" ):
124127 continue
0 commit comments