Created
May 14, 2020 16:51
-
-
Save BrianJakovich/da1e6920a053e2113abc3d8b985dfe0b to your computer and use it in GitHub Desktop.
workspaces-image-factory-scripts-setup_workspace.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import string | |
import json | |
def find_id_of_workspace(): | |
cloudformation = boto3.resource('cloudformation') | |
stack = cloudformation.Stack('WorkspaceBuilder') | |
stack_resource = stack.Resource('workspace1').physical_resource_id | |
return stack_resource | |
def update_workspace_running_mode(): | |
workspaces = boto3.client('workspaces') | |
workspace_id = find_id_of_workspace() | |
workspaces.modify_workspace_properties( | |
WorkspaceId=workspace_id, | |
WorkspaceProperties={ | |
'RunningMode': 'AUTO_STOP', | |
'RunningModeAutoStopTimeoutInMinutes': 60 | |
} | |
) | |
def main(): | |
update_workspace_running_mode() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
View here: https://github.com/VerticalRelevance/workspaces-image-factory/blob/master/scripts/setup_workspace.py