Request a VPC peering connection between two VPCs.

    .. versionadded:: 2016.11.0

    requester_vpc_id
        ID of the requesting VPC. Exclusive with requester_vpc_name.

    requester_vpc_name
        Name tag of the requesting VPC.  Exclusive with requester_vpc_id.

    peer_vpc_id
        ID of the VPC to create VPC peering connection with. This can be a VPC in
        another account. Exclusive with peer_vpc_name.

    peer_vpc_name
        Name tag of the VPC to create VPC peering connection with. This can only
        be a VPC in the same account and same region, else resolving it into a
        vpc ID will almost certainly fail. Exclusive with peer_vpc_id.

    name
        The name to use for this VPC peering connection.

    peer_owner_id
        ID of the owner of the peer VPC. Defaults to your account ID, so a value
        is required if peering with a VPC in a different account.

    peer_region
        Region of peer VPC. For inter-region vpc peering connections. Not required
        for intra-region peering connections.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string) that
        contains a dict with region, key and keyid.

    dry_run
        If True, skip application and return status.

    CLI Example:

    .. code-block:: bash

        # Create a named VPC peering connection
        salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da name=my_vpc_connection
        # Without a name
        salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da
        # Specify a region
        salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da region=us-west-2

def request_vpc_peering_connection(requester_vpc_id=None, requester_vpc_name=None,
                                   peer_vpc_id=None, peer_vpc_name=None, name=None,
                                   peer_owner_id=None, peer_region=None, region=None,
                                   key=None, keyid=None, profile=None, dry_run=False):
    '''
    Request a VPC peering connection between two VPCs.

    .. versionadded:: 2016.11.0

    requester_vpc_id
        ID of the requesting VPC. Exclusive with requester_vpc_name.

    requester_vpc_name
        Name tag of the requesting VPC.  Exclusive with requester_vpc_id.

    peer_vpc_id
        ID of the VPC to create VPC peering connection with. This can be a VPC in
        another account. Exclusive with peer_vpc_name.

    peer_vpc_name
        Name tag of the VPC to create VPC peering connection with. This can only
        be a VPC in the same account and same region, else resolving it into a
        vpc ID will almost certainly fail. Exclusive with peer_vpc_id.

    name
        The name to use for this VPC peering connection.

    peer_owner_id
        ID of the owner of the peer VPC. Defaults to your account ID, so a value
        is required if peering with a VPC in a different account.

    peer_region
        Region of peer VPC. For inter-region vpc peering connections. Not required
        for intra-region peering connections.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string) that
        contains a dict with region, key and keyid.

    dry_run
        If True, skip application and return status.

    CLI Example:

    .. code-block:: bash

        # Create a named VPC peering connection
        salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da name=my_vpc_connection
        # Without a name
        salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da
        # Specify a region
        salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da region=us-west-2

    '''
    conn = _get_conn3(region=region, key=key, keyid=keyid,
                      profile=profile)

    if name and _vpc_peering_conn_id_for_name(name, conn):
        raise SaltInvocationError('A VPC peering connection with this name already '
                                  'exists! Please specify a different name.')

    if not _exactly_one((requester_vpc_id, requester_vpc_name)):
        raise SaltInvocationError('Exactly one of requester_vpc_id or '
                                  'requester_vpc_name is required')
    if not _exactly_one((peer_vpc_id, peer_vpc_name)):
        raise SaltInvocationError('Exactly one of peer_vpc_id or '
                                  'peer_vpc_name is required.')

    if requester_vpc_name:
        requester_vpc_id = _get_id(vpc_name=requester_vpc_name, region=region, key=key,
                         keyid=keyid, profile=profile)
        if not requester_vpc_id:
            return {'error': 'Could not resolve VPC name {0} to an ID'.format(requester_vpc_name)}
    if peer_vpc_name:
        peer_vpc_id = _get_id(vpc_name=peer_vpc_name, region=region, key=key,
                         keyid=keyid, profile=profile)
        if not peer_vpc_id:
            return {'error': 'Could not resolve VPC name {0} to an ID'.format(peer_vpc_name)}

    peering_params = {"VpcId": requester_vpc_id, "PeerVpcId": peer_vpc_id, "DryRun": dry_run}

    if peer_owner_id:
        peering_params.update({"PeerOwnerId": peer_owner_id})
    if peer_region:
        peering_params.update({"PeerRegion": peer_region})

    try:
        log.debug('Trying to request vpc peering connection')
        vpc_peering = conn.create_vpc_peering_connection(**peering_params)
        peering = vpc_peering.get('VpcPeeringConnection', {})
        peering_conn_id = peering.get('VpcPeeringConnectionId', 'ERROR')
        msg = 'VPC peering {0} requested.'.format(peering_conn_id)
        log.debug(msg)

        if name:
            log.debug('Adding name tag to vpc peering connection')
            conn.create_tags(
                Resources=[peering_conn_id],
                Tags=[{'Key': 'Name', 'Value': name}]
            )
            log.debug('Applied name tag to vpc peering connection')
            msg += ' With name {0}.'.format(name)

        return {'msg': msg}
    except botocore.exceptions.ClientError as err:
        log.error('Got an error while trying to request vpc peering')
        return {'error': __utils__['boto.get_error'](err)}