Empowering AI Agents with Secure Desktop Access: A Step-by-Step Guide to Amazon WorkSpaces for Agents

By ● min read

Overview

Enterprise workflows often rely on legacy desktop applications that lack modern APIs. According to a 2024 Gartner report, 75% of organizations run such applications, making it difficult for AI agents to automate processes. Amazon WorkSpaces now allows AI agents to securely operate these applications without requiring costly modernization. By leveraging the same managed virtual desktops used by employees, you can give agents governed access to desktop environments. This tutorial walks you through setting up a WorkSpaces environment for AI agents, from creating a stack to integrating with agent frameworks like LangChain or CrewAI.

Empowering AI Agents with Secure Desktop Access: A Step-by-Step Guide to Amazon WorkSpaces for Agents
Source: aws.amazon.com

Prerequisites

Before you begin, ensure you have the following:

Step-by-Step Instructions

1. Create a WorkSpaces Applications Stack

Start by navigating to the Amazon WorkSpaces console. Under Applications, choose Create stack. This defines the environment for your agents.

  1. Name and Configuration – Enter a stack name (e.g., AI-Agents-Stack).
  2. Fleet Association – Select an existing WorkSpaces fleet or create a new one. The fleet determines the compute resources for agent sessions.
  3. VPC Endpoints – Configure at least one interface VPC endpoint for WorkSpaces (required for agent connectivity).
  4. AI Agent Access – In Step 3 of the creation workflow, you'll see two options:
    • No AI agent access (default for human users)
    • Add AI Agents – Select this to enable agent access.

After choosing Add AI Agents, specify an IAM role that the agent will assume. This role must have permissions to call workSpaces:StartApplication and workSpaces:GetApplication. Review and create the stack.

2. Configure the Application for the Agent

Once the stack is ready, create an application within it. This application points to the desktop session the agent will use.

  1. In the WorkSpaces console, go to Applications and choose Create application.
  2. Select the stack you just created.
  3. Provide details:
    • Application name (e.g., MainframeLegacyApp)
    • Desktop image – Choose a WorkSpaces bundle that includes the required legacy software.
    • Agent permissions – Define which actions the agent can perform (e.g., click, type, read screen).
  4. Ensure the application uses MCP (Model Context Protocol). This is enabled by default, but verify in the advanced settings.

3. Set Up IAM Permissions for the Agent

Create or update an IAM role for your agent. Attach the following policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "workSpaces:StartApplication",
        "workSpaces:GetApplication",
        "workSpaces:DescribeApplications"
      ],
      "Resource": "*"
    }
  ]
}

Additionally, grant the agent permission to assume this role from its identity provider.

4. Connect Your Agent Framework

Amazon WorkSpaces supports MCP, so any agent framework that implements it can connect. Below is an example using LangChain with the WorkSpacesTool (hypothetical wrapper):

Empowering AI Agents with Secure Desktop Access: A Step-by-Step Guide to Amazon WorkSpaces for Agents
Source: aws.amazon.com
from langchain.agents import initialize_agent, Tool
from langchain_community.agent_toolkits import WorkSpacesToolkit

# Configure the toolkit with your stack and application IDs
work_toolkit = WorkSpacesToolkit(
    stack_id="your-stack-id",
    application_id="your-application-id",
    iam_role_arn="arn:aws:iam::123456789012:role/AgentWorkSpacesRole"
)

# Create a tool for the agent
work_tool = Tool(
    name="DesktopApplication",
    func=work_toolkit.run,
    description="Useful for interacting with legacy desktop applications via WorkSpaces."
)

# Initialize agent
agent = initialize_agent(
    tools=[work_tool],
    llm=your_llm,
    agent="zero-shot-react-description",
    verbose=True
)

agent.run("Open the mainframe terminal and run quarterly report generation.")

For CrewAI, you would similarly define a WorkSpaces agent that can be called within a Crew. For Strands Agents, configure the MCP endpoint URL provided in the stack details.

5. Validate Audit Trails and Security

After deploying, monitor agent sessions via AWS CloudTrail (logs all API calls) and Amazon CloudWatch (application metrics).

  1. Enable CloudTrail for the WorkSpaces namespace.
  2. Set up CloudWatch dashboards to track session duration, errors, and resource usage.
  3. Verify that your existing security controls (e.g., VPC security groups, encryption at rest) apply to agent sessions.

Common Mistakes

Summary

Amazon WorkSpaces now allows AI agents to securely operate legacy desktop applications without APIs or migrations. This guide covered creating a WorkSpaces Applications stack, configuring IAM permissions, and connecting agent frameworks via MCP. By following these steps, you can modernize your enterprise workflows while maintaining security and auditability. Start by reviewing the prerequisites and then build your first agent-enabled WorkSpace.

Tags:

Recommended

Discover More

The New AI Partnership Landscape: How AWS Emerges as the Big Winner from OpenAI's Microsoft ResetSamsung's Smart Glasses on the Horizon: What to Expect at the Next Galaxy UnpackedMotorola Razr Fold vs. Samsung Galaxy Z Fold 7: 10 Key Differences That Make One a Clear WinnerHow Universities Can Shape the Next Generation of Social EntrepreneursHow to Spot and Handle AI Customer Service Interactions Without Falling for the Illusion