activities
latest
false
UiPath logo, featuring letters U and I in white
IT Automation Activities
Last updated Nov 15, 2024

Provision and Manage Amazon WorkSpaces

The example below explains how to use Amazon WorkSpaces activities to automate provisioning and cost savings tasks. It presents activities such as Amazon Workspaces Scope, Create Workspace, For Each Workspace, Reboot Workspace, Stop Workspace, Update Workspace, or Remove Workspace. You can find these activities in the UiPath.AmazonWorkSpaces.Activities package.

The example contains two workflows:

Create_Workspace.xaml

Provisions a new WorkSpace for a given directory user by:

  • preparing the tags to be associated with the WorkSpace, including a tag with key=CreationDate, to store the creation date info, because Amazon WorkSpaces API does not provide this value;
  • specifying the bundle, directory, username, running mode, tags, etc.

Manage_Workspaces.xaml

Performs IT management tasks for the WorkSpaces in a specified directory by:

  • identifying and rebooting unhealthy WorkSpaces;
  • stopping WorkSpaces that are available, but in a disconnected state (cost optimization);
  • identifying unused WorkSpaces and based on an inactivity period, taking one of these actions:

    • sending a warning email to the user;
    • permanently removing the WorkSpace (cost optimization).

Provision a WorkSpace

This is how the first automation process, Create_Workspace.xaml, which connects to Amazon Web Services and creates a new WorkSpace, can be built:

  1. Add the Amazon Workspace Scope activity to connect to Amazon Web Services and also to provide a scope for the Amazon WorkSpaces activities. Then specify either Access Keys (i.e., AccessKeyId & SecretAccessKey) or an IAMRole (when the robot is running within an EC2 instance). In this example, we are connecting using Access Keys.


    Note: For more details about creating an AWS secret key, please read this article: Create an AWS access key.
  2. A new WorkSpace is provisioned using the Create Workspace activity.



Manage WorkSpaces

This is how the second automation process, Manage_Workspaces.xaml, which retrieves all WorkSpaces in a specified directory, can be built:

  1. Follow the same instructions as in step 1 from Provision a WorkSpace.
  2. Use the For Each Workspace activity with FilterBy set to DirectoryId. Then provide your directory ID in the FilterValue property.


    Note: The For Each Workspace activity supports filtering by DirectoryId, BundleId, and WorkspaceIds.

For each WorkSpace matching the filter criteria, let’s check if one of the actions below should be performed.

Reboot an unhealthy WorkSpace
If the state of the WorkSpace is AWRKSState.UNHEALTHY, reboot the WorkSpace by using the Reboot Workspace activity.


Since this activity can take a long time, it is recommended to set the value of the WaitForCompletion property to False.
Stop a WorkSpace that is disconnected

Stop a WorkSpace that is disconnected for more than 30 minutes.

If the running mode of the WorkSpace is AutoStop and the user is disconnected for more than MinutesSinceDisconnected minutes, stop it by calling the Stop Workspace activity with WaitForCompletion set to False.


Send a warning email

Send a warning email to the user if the WorkSpace has not been used in the past 30 days.

If the WorkSpace was not used in the past InactivityPeriodBeforeWarning days, the user will receive an email saying the WorkSpace will be permanently removed in 7 days, i.e. InactivityPeriodBeforeRemoving - InactivityPeriodBeforeWarning = 37 – 30 = 7.


Use the Send Outlook Mail Message activity to send the warning email.



In addition, to keep a record of the admin action performed, add a tag/tags to the WorkSpace. Use the Update Workspace activity to add such tags.





Permanently remove a WorkSpace

Remove a WorkSpace that has not been used in the last 37 days.

If the WorkSpace was not used in the past InactivityPeriodBeforeRemoving days, it will be terminated. For this action, use the Remove Workspace activity with WaitForCompletion set to False.


Permanently remove a WorkSpace that has never been used

Remove a WorkSpace that has never been used since its creation happening more than 37 days ago.

This situation can be checked only when WorkSpace.LastKnownUserConnectionTimestamp = new DateTime() (i.e. never used) and the WorkSpace has a tag that stores the creation date (because Amazon WorkSpaces API does not provide this value).
If the WorkSpace was never used and creationDate <= Today.Date.AddDays(-InactivityPeriodBeforeRemoving), it will be permanently removed.


Run the process. The robot uses the Amazon WorkSpaces activities to automate your Amazon WorkSpaces tasks.

  • Provision a WorkSpace
  • Manage WorkSpaces

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.