code: def on_before_transform_resource(self, logical_id, resource_type, resource_properties):
          
  
          if not self._is_supported(resource_type):
              return
  
          function_policies = FunctionPolicies(resource_properties, self._policy_template_processor)
  
          if len(function_policies) == 0:
              # No policies to process
              return
  
          result = []
          for policy_entry in function_policies.get():
  
              if policy_entry.type is not PolicyTypes.POLICY_TEMPLATE:
                  # If we don't know the type, skip processing and pass to result as is.
                  result.append(policy_entry.data)
                  continue
  
              # We are processing policy templates. We know they have a particular structure:
              # {"templateName": { parameter_values_dict }}
              template_data = policy_entry.data
              template_name = list(template_data.keys())[0]
              template_parameters = list(template_data.values())[0]
  
              try:
  
                  # 'convert' will return a list of policy statements
                  result.append(self._policy_template_processor.convert(template_name, template_parameters))
  
              except InsufficientParameterValues as ex:
                  # Exception's message will give lot of specific details
                  raise InvalidResourceException(logical_id, str(ex))
              except InvalidParameterValues:
                  raise InvalidResourceException(logical_id,
                                                 "Must specify valid parameter values for policy template '{}'"
                                                 .format(template_name))
  
          # Save the modified policies list to the input
          resource_properties[FunctionPolicies.POLICIES_PROPERTY_NAME] = result
docs: Hook method that gets called before "each" SAM resource gets processed
  
          :param string logical_id: Logical ID of the resource being processed
          :param string resource_type: Type of the resource being processed
          :param dict resource_properties: Properties of the resource
          :return: Nothing