Given a valid config, update the policy for a bucket.

    Returns {updated: true} if policy was updated and returns
    {updated: False} if policy was not updated.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_s3_bucket.put_policy my_bucket {...}

def put_policy(Bucket, Policy,
           region=None, key=None, keyid=None, profile=None):
    '''
    Given a valid config, update the policy for a bucket.

    Returns {updated: true} if policy was updated and returns
    {updated: False} if policy was not updated.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_s3_bucket.put_policy my_bucket {...}

    '''

    try:
        conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
        if Policy is None:
            Policy = '{}'
        elif not isinstance(Policy, six.string_types):
            Policy = salt.utils.json.dumps(Policy)
        conn.put_bucket_policy(Bucket=Bucket, Policy=Policy)
        return {'updated': True, 'name': Bucket}
    except ClientError as e:
        return {'updated': False, 'error': __utils__['boto3.get_error'](e)}