in Gems/AWSCore/Code/Tools/ResourceMappingTool/utils/json_utils.py [0:0]
def validate_json_dict_according_to_json_schema(json_dict: Dict[str, any]) -> None:
# The reason we keep this manual json schema validation is python missing supportive feature in default libs
# When it is ready, we should be able to replace this with straightforward lib function call
root_property: str
for root_property in _RESOURCE_MAPPING_SCHEMA_REQUIRED_ROOT_PROPERTIES:
_validate_required_key_in_json_dict(json_dict, "root", root_property)
if not re.match(_RESOURCE_MAPPING_SCHEMA_ACCOUNTID_PATTERN, json_dict[RESOURCE_MAPPING_ACCOUNTID_JSON_KEY_NAME]):
raise ValueError(error_messages.INVALID_FORMAT_UNEXPECTED_VALUE_IN_FILE_ERROR_MESSAGE.format(
json_dict[RESOURCE_MAPPING_ACCOUNTID_JSON_KEY_NAME],
f"root/{RESOURCE_MAPPING_ACCOUNTID_JSON_KEY_NAME}",
_RESOURCE_MAPPING_SCHEMA_ACCOUNTID_PATTERN))
if not re.match(_RESOURCE_MAPPING_SCHEMA_REGION_PATTERN, json_dict[_RESOURCE_MAPPING_REGION_JSON_KEY_NAME]):
raise ValueError(error_messages.INVALID_FORMAT_UNEXPECTED_VALUE_IN_FILE_ERROR_MESSAGE.format(
json_dict[_RESOURCE_MAPPING_REGION_JSON_KEY_NAME],
f"root/{_RESOURCE_MAPPING_REGION_JSON_KEY_NAME}",
_RESOURCE_MAPPING_SCHEMA_REGION_PATTERN))
json_resources: Dict[str, any] = json_dict[_RESOURCE_MAPPING_JSON_KEY_NAME]
if json_resources:
resource_key: str
resource_value: Dict[str, str]
for resource_key, resource_value in json_resources.items():
resource_property: str
for resource_property in _RESOURCE_MAPPING_SCHEMA_REQUIRED_RESOURCE_PROPERTIES:
_validate_required_key_in_json_dict(resource_value, resource_key, resource_property)