import click


def require_region(ctx, param, value):
    """
    Require region to be set in parameter or in context
    :param ctx: Context
    :param param: Click Parameter
    :param value: Parameter value
    :return: Parameter value
    """
    if not value and not ctx.obj.config.region:
        raise click.BadParameter(f'{param.name} is required for {ctx.command.name}')
    return value