Maximize WorkDocs Using AWS Lambda Functions

How AWS Lambda Functions Can Be Used to Automate and Advance WorkDocs Document Repository

  By: Courtney Dooley | Technical Architect


Amazon Web Services WorkDocs is a simple document repository that has a user-friendly interface and search capabilities. A key element of WorkDocs is its API library and the ability to extend and automate functionality from most third-party process workflows. Below are three ways Lambda functions can use the WorkDocs API library to automate functionality for Folder Automation, Permissions Management, and Comments & Labels.

Folder Automation

Custom REST APIs can be created using Lambda functions triggered by APIs created in AWS API Gateway. These functions can complete folder and file modifications within WorkDocs. The API calls can create a folder in a specific existing folder or user root folder based on data provided by the API request. Even if data isn’t entirely known, such as the parent folder id, providing an owner-user and folder name can get the parent folder id using the describeUsers and describeFolderContents APIs.

If a folder or file needs to be renamed, it can be updated using the WorkDocs updateDocument and updateFolder APIs. The same functions can be used to move a file or folder from one location to another by specifying an alternative “ParentFolderId” parameter.

Finally, when content is ready for cleanup, a file or folder can be deleted using the deleteFolder, deleteDocument, and deleteFolderContents APIs. These functions move the content to the owner’s recycle bin where it can be restored or permanently deleted by the owner. The retention time limit for all recycle bins can be set via the administration settings within WorkDocs.

Permissions Management

Using the describeUsers WorkDocs API, a specific user can be identified by specifying the user’s login as the “Query” parameter. If the user has not been activated for WorkDocs, that activation can be done using the activateUser WorkDocs API. Once active, that user’s id can be added as an owner, co-owner, contributor, or viewer of any resource by using the addResourcePermissions API. All calls can be completed in the same Lambda function and requested specifying all details at once.

Specific users can be removed from a file or folder by using the removeResourcePermissions, or all permissions can be removed using the removeAllResourcePermissions API. The remove all can be used to start over and add new permissions to the resource as part of a custom “Replace All” functionality.

Users can also be notified of these changes by setting the “Notifications” JSON parameter in the addResourcePermissions. By setting the “EmailMessage” value and “SetEmail” to true within the “Notifications,” an email alert will be sent to the user informing them of the permissions change. Setting “SetEmail” value to false will keep the notification from being sent and the user will not know of the change other than seeing the resource in the “Shared with me” view.

Users can also be deactivated, deleted, created, and modified using the WorkDocs API library to allow for a full range of provisioning via Lambda functions.

Comments & Labels

Although WorkDocs does not have metadata in the traditional sense (at least not at the time of this blog post), labels and comments can be searched, which gives a unique ability to values set using those features.

Comments are available as feedback when viewing documents and are not available on folders, however, labels are not exposed to the user interface at this time and can be set on folders and documents independently.

Lambda functions can be used to get, set, and delete comments or labels on a resource using the below set of API functions:

  • – createComment
  • – deleteComment
  • – describeComments
  • – createLabels
  • – deleteLabels

describeFolder and describeDocument include the labels assigned to that resource. deleteLabels allows for a parameter to “DeleteAll” rather than just a specific label.

All APIs mentioned in this blog are available out of the box with WorkDocs and can be combined to create a custom solution that meets the demands of custom web services, process workflows, and other integrated applications.

AWS offers a robust and expansive set of services to implement custom solutions quickly and easily.

Contact us for more tips and tricks on developing AWS Cloud Solutions!