def set(self, logicalId, resource):
        """
        Adds the resource to dictionary with given logical Id. It will overwrite, if the logicalId is already used.

        :param string logicalId: Logical Id to set to
        :param SamResource or dict resource: The actual resource data
        """

        resource_dict = resource
        if isinstance(resource, SamResource):
            resource_dict = resource.to_dict()

        self.resources[logicalId] = resource_dict