def present(
        name,
        attributes,
        region=None,
        key=None,
        keyid=None,
        profile=None):
    ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
    alarm_details = __salt__['boto_cloudwatch.get_alarm'](
        name, region, key, keyid, profile
    )

    # Convert to arn's
    for k in ["alarm_actions", "insufficient_data_actions", "ok_actions"]:
        if k in attributes:
            attributes[k] = __salt__['boto_cloudwatch.convert_to_arn'](
                attributes[k], region, key, keyid, profile
            )

    # Diff the alarm_details with the passed-in attributes, allowing for the
    # AWS type transformations
    difference = []
    if alarm_details:
        for k, v in six.iteritems(attributes):
            if k not in alarm_details:
                difference.append("{0}={1} (new)".format(k, v))
                continue
            v2 = alarm_details[k]
            if v == v2:
                continue
            if isinstance(v, six.string_types) and str(v) == str(v2):
                continue
            if isinstance(v, float) and v == float(v2):
                continue
            if isinstance(v, int) and v == int(v2):
                continue
            if isinstance(v, list) and sorted(v) == sorted(v2):
                continue
            difference.append("{0}='{1}' was: '{2}'".format(k, v, v2))
    else:
        difference.append("new alarm")
    create_or_update_alarm_args = {
        "name": name,
        "region": region,
        "key": key,
        "keyid": keyid,
        "profile": profile
    }
    create_or_update_alarm_args.update(attributes)
    if alarm_details:   # alarm is present.  update, or do nothing
        # check to see if attributes matches is_present. If so, do nothing.
        if len(difference) == 0:
            ret['comment'] = "alarm {0} present and matching".format(name)
            return ret
        if __opts__['test']:
            msg = 'alarm {0} is to be created/updated.'.format(name)
            ret['comment'] = msg
            ret['result'] = None
            return ret
        result = __salt__['boto_cloudwatch.create_or_update_alarm'](
            **create_or_update_alarm_args
        )
        if result:
            ret['changes']['diff'] = difference
        else:
            ret['result'] = False
            ret['comment'] = 'Failed to create {0} alarm'.format(name)
    else:  # alarm is absent. create it.
        if __opts__['test']:
            msg = 'alarm {0} is to be created/updated.'.format(name)
            ret['comment'] = msg
            ret['result'] = None
            return ret
        result = __salt__['boto_cloudwatch.create_or_update_alarm'](
            **create_or_update_alarm_args
        )
        if result:
            ret['changes']['new'] = attributes
        else:
            ret['result'] = False
            ret['comment'] = 'Failed to create {0} alarm'.format(name)
    return ret
Ensure the cloudwatch alarm exists.
dataset/ETHPy150Open saltstack/salt/salt/states/boto_cloudwatch_alarm.py/present