'Mock response for localhost metadata
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html'

def metadata_response(self, request, full_url, headers):

    parsed_url = urlparse(full_url)
    tomorrow = (datetime.datetime.utcnow() + datetime.timedelta(days=1))
    credentials = dict(AccessKeyId=u'test-key', SecretAccessKey=u'test-secret-key', Token=u'test-session-token', Expiration=tomorrow.strftime(u'%Y-%m-%dT%H:%M:%SZ'))
    path = parsed_url.path
    meta_data_prefix = u'/latest/meta-data/'
    if path.startswith(meta_data_prefix):
        path = path[len(meta_data_prefix):]
    if (path == u''):
        result = u'iam'
    elif (path == u'iam'):
        result = json.dumps({u'security-credentials': {u'default-role': credentials}})
    elif (path == u'iam/security-credentials/'):
        result = u'default-role'
    elif (path == u'iam/security-credentials/default-role'):
        result = json.dumps(credentials)
    else:
        raise NotImplementedError(u'The    {0}    metadata    path    has    not    been    implemented'.format(path))
    return (200, headers, result)
