Ensure RDS replica exists.

    .. code-block:: yaml

        Ensure myrds replica RDS exists:
          boto_rds.create_replica:
            - name: myreplica
            - source: mydb

def replica_present(name, source, db_instance_class=None,
                    availability_zone=None, port=None,
                    auto_minor_version_upgrade=None, iops=None,
                    option_group_name=None, publicly_accessible=None,
                    tags=None, region=None, key=None, keyid=None,
                    profile=None, db_parameter_group_name=None):
    '''
    Ensure RDS replica exists.

    .. code-block:: yaml

        Ensure myrds replica RDS exists:
          boto_rds.create_replica:
            - name: myreplica
            - source: mydb
    '''
    ret = {'name': name,
           'result': True,
           'comment': '',
           'changes': {}
           }
    replica_exists = __salt__['boto_rds.exists'](name, tags, region, key,
                                                 keyid, profile)
    if not replica_exists.get('exists'):
        if __opts__['test']:
            ret['comment'] = 'RDS read replica {0} is set to be created '.format(name)
            ret['result'] = None
            return ret
        created = __salt__['boto_rds.create_read_replica'](name, source,
                                                           db_instance_class,
                                                           availability_zone, port,
                                                           auto_minor_version_upgrade,
                                                           iops, option_group_name,
                                                           publicly_accessible,
                                                           tags, region, key,
                                                           keyid, profile)
        if created:
            ret['comment'] = 'RDS replica {0} created.'.format(name)
            ret['changes']['old'] = {'instance': None}
            ret['changes']['new'] = {
                  'instance': __salt__['boto_rds.describe_db_instances'](
                  name=name, jmespath='DBInstances[0]', region=region,
                  key=key, keyid=keyid, profile=profile)}
        else:
            ret['result'] = False
            ret['comment'] = 'Failed to create RDS replica {0}.'.format(name)
    else:
        jmespath = 'DBInstances[0].DBParameterGroups[0].DBParameterGroupName'
        pmg_name = __salt__['boto_rds.describe_db_instances'](name=name,
              jmespath=jmespath, region=region, key=key, keyid=keyid,
              profile=profile)
        pmg_name = pmg_name[0] if pmg_name else None
        if pmg_name != db_parameter_group_name:
            modified = __salt__['boto_rds.modify_db_instance'](
                  name=name, db_parameter_group_name=db_parameter_group_name,
                  region=region, key=key, keyid=keyid, profile=profile)
            if not modified:
                ret['result'] = False
                ret['comment'] = ('Failed to update parameter group of {0} RDS '
                                  'instance.'.format(name))
            ret['changes']['old'] = pmg_name
            ret['changes']['new'] = db_parameter_group_name
        ret['result'] = True
        ret['comment'] = 'RDS replica {0} exists.'.format(name)
    return ret