Delete an internet gateway (by name or id).

    Returns True if the internet gateway was deleted and otherwise False.

    .. versionadded:: 2015.8.0

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.delete_internet_gateway internet_gateway_id=igw-1a2b3c
        salt myminion boto_vpc.delete_internet_gateway internet_gateway_name=myigw

def delete_internet_gateway(internet_gateway_id=None,
                            internet_gateway_name=None,
                            detach=False, region=None,
                            key=None, keyid=None, profile=None):
    '''
    Delete an internet gateway (by name or id).

    Returns True if the internet gateway was deleted and otherwise False.

    .. versionadded:: 2015.8.0

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.delete_internet_gateway internet_gateway_id=igw-1a2b3c
        salt myminion boto_vpc.delete_internet_gateway internet_gateway_name=myigw

    '''

    try:
        if internet_gateway_name:
            internet_gateway_id = _get_resource_id('internet_gateway',
                                                   internet_gateway_name,
                                                   region=region, key=key,
                                                   keyid=keyid, profile=profile)
        if not internet_gateway_id:
            return {'deleted': False, 'error': {
                    'message': 'internet gateway {0} does not exist.'.format(
                        internet_gateway_name)}}

        if detach:
            igw = _get_resource('internet_gateway',
                                resource_id=internet_gateway_id, region=region,
                                key=key, keyid=keyid, profile=profile)

            if not igw:
                return {'deleted': False, 'error': {
                        'message': 'internet gateway {0} does not exist.'.format(
                            internet_gateway_id)}}

            if igw.attachments:
                conn = _get_conn(region=region, key=key, keyid=keyid,
                                 profile=profile)
                conn.detach_internet_gateway(internet_gateway_id,
                                             igw.attachments[0].vpc_id)
        return _delete_resource('internet_gateway',
                                resource_id=internet_gateway_id,
                                region=region, key=key, keyid=keyid,
                                profile=profile)
    except BotoServerError as e:
        return {'deleted': False, 'error': __utils__['boto.get_error'](e)}