def get_detached_volumes(
    client: boto3.client, next_token: str = None, results: List[Dict[str, Any]] = None
):
    results = results or []
    params = dict(Filters=[{"Name": "tag-key", "Values": ["ChaosToolkitDetached"]}])
    if next_token:
        params["NextToken"] = next_token
    response = client.describe_volumes(**params)
    results.extend([r for r in response["Volumes"]])
    if response.get("NextToken"):
        get_detached_volumes(response["NextToken"], results)
    return results
예제 #2
0
def get_detached_volumes(client: boto3.client,
                         next_token: str = None,
                         results: List[Dict[str, Any]] = None):
    results = results or []
    params = dict(Filters={
        'Name': 'tag-key',
        'Values': ['ChaosToolkitDetached']
    })
    if next_token:
        params['NextToken'] = next_token
    response = client.describe_volumes(**params)
    results.extend([r for r in response['Volumes']])
    if response.get('NextToken'):
        get_detached_volumes(response['NextToken'], results)
    return results