def _add_combined_condition_to_template(self, template_dict, condition_name, conditions_to_combine):
        """
        Add top-level template condition that combines the given list of conditions.

        :param dict template_dict: SAM template dictionary
        :param string condition_name: Name of top-level template condition
        :param list conditions_to_combine: List of conditions that should be combined (via OR operator) to form
                                           top-level condition.
        """
        # defensive precondition check
        if not conditions_to_combine or len(conditions_to_combine) < 2:
            raise ValueError('conditions_to_combine must have at least 2 conditions')

        template_conditions = template_dict.setdefault('Conditions', {})
        new_template_conditions = make_combined_condition(sorted(list(conditions_to_combine)), condition_name)
        for name, definition in new_template_conditions.items():
            template_conditions[name] = definition
Example #2
0
    def _add_combined_condition_to_template(self, template_dict, condition_name, conditions_to_combine):
        """
        Add top-level template condition that combines the given list of conditions.

        :param dict template_dict: SAM template dictionary
        :param string condition_name: Name of top-level template condition
        :param list conditions_to_combine: List of conditions that should be combined (via OR operator) to form
                                           top-level condition.
        """
        # defensive precondition check
        if not conditions_to_combine or len(conditions_to_combine) < 2:
            raise ValueError('conditions_to_combine must have at least 2 conditions')

        template_conditions = template_dict.setdefault('Conditions', {})
        new_template_conditions = make_combined_condition(sorted(list(conditions_to_combine)), condition_name)
        for name, definition in new_template_conditions.items():
            template_conditions[name] = definition