def iterate(self, resource_type=None):
for logicalId, resource_dict in self.resources.items():<EOL><INDENT>resource = SamResource(resource_dict)<EOL>needs_filter = resource.valid()<EOL>if resource_type:<EOL><INDENT>needs_filter = needs_filter and resource.type == resource_type<EOL><DEDENT>if needs_filter:<EOL><INDENT>yield logicalId, resource<EOL><DEDENT><DEDENT>
Iterate over all resources within the SAM template, optionally filtering by type

:param string resource_type: Optional type to filter the resources by
:yields (string, SamResource): Tuple containing LogicalId and the resource