简体   繁体   中英

Iterate through aws workspaces using python boto3

I am trying to print all the AWS Workspaces available in a specific region.

I have tried using the code :

import boto3
client = boto3.client('workspaces')
counter = client.describe_workspaces()
print counter()

But "print counter()" is print a lot of values which I am not sure about, how can I store the Workspace ID in the "counter" variable so that I can iterate through them.

WorkspaceID is part of the response, all you need to do is iterate through the list returned. docs

You can get a list of IDs like this,

import boto3
client = boto3.client('workspaces')

workspaces = client.describe_workspaces()['Workspaces']
workspaceIds = [workspace['WorkspaceId'] for workspace in workspaces]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM