def read_creds_from_ecs_container_metadata():
    """
    Read credentials from ECS instance metadata (IAM role)

    :return:
    """
    creds = init_creds()
    try:
        ecs_metadata_relative_uri = os.environ['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']
        credentials = requests.get('http://169.254.170.2' + ecs_metadata_relative_uri, timeout = 1).json()
        for c in ['AccessKeyId', 'SecretAccessKey']:
            creds[c] = credentials[c]
            creds['SessionToken'] = credentials['Token']
        return creds
    except Exception as e:
        return False
Read credentials from ECS instance metadata (IAM role)

    :return: