The Simplest Way to Make Ec2 Systems Manager and Temporal Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running ec2 systems manager and temporal together lets teams automate fleet tasks with durable state. Temporal tracks the workflow steps while EC2 Systems Manager runs the actual host commands. This setup removes the need for open network ports or fragile shell scripts. Your team gets repeatable jobs that recover from host errors on their own. Many groups start with basic scripts to run updates across cloud servers. Scripts fail when a server restarts or a network link drops mid-task. By pairi

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Running ec2 systems manager and temporal together lets teams automate fleet tasks with durable state. Temporal tracks the workflow steps while EC2 Systems Manager runs the actual host commands.

This setup removes the need for open network ports or fragile shell scripts. Your team gets repeatable jobs that recover from host errors on their own.

Many groups start with basic scripts to run updates across cloud servers. Scripts fail when a server restarts or a network link drops mid-task. By pairing these two tools, one system remembers the step while the other executes it. This keeps your server fleet steady during long patch cycles or app rollouts.

How ec2 systems manager and temporal pass tasks and keys

A Temporal worker acts as the bridge between your workflow logic and AWS. The worker pulls tasks from the Temporal server queue and calls the AWS API. To do this safely, the worker needs an IAM role with scoped permissions. It should not use static keys stored on disk or in code.

When a step starts, the worker sends a command request to EC2 Systems Manager. An agent on the target EC2 host picks up that request and runs it. The agent uses its own instance profile to talk back to the AWS service. Data flows through AWS APIs rather than direct SSH links between your servers.

Because commands take time to finish, the worker should not block and wait. Instead, the worker polls for command status or listens for state change events. CloudWatch Events can catch the finish signal and tell Temporal the step is done. Then the workflow moves to the next server batch in your fleet.

Fixing wide roles and blind spots in host workflows

The biggest risk in this setup is giving the Temporal worker a broad role. If a worker can run commands on any host, one bad task hits everything. Attackers or bugs could trigger commands on production databases instead of test web nodes. Teams must scope worker roles using resource tags and strict condition rules.

GCP Access Context Manager + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Shared service accounts also create major blind spots in your security audit logs. When every workflow uses the same worker role, CloudTrail only shows that single role. You lose track of which team or workflow triggered a sensitive host change. Passing caller context into the session tags helps link actions back to specific jobs.

Another common failure happens when command outputs contain sensitive data like emails or card numbers. If the agent sends raw stdout back to the worker, those secrets land in history. Temporal workflow history keeps data for a long time and many developers can read it. You should keep command output small and store raw logs in locked storage buckets.

Scoping network paths and instance roles for safe runs

Good fleet safety starts by splitting Temporal workers by their job type and environment. Run one worker pool for dev tasks and a separate pool for production changes. Give each pool its own IAM role restricted to matching host resource tags. A dev worker will fail right away if it tries to touch production hosts.

Lock down the EC2 instance profile on each target server as well. The host agent only needs permissions to read messages and write logs to storage. Do not attach admin policies to the instance role just to make scripts work. Keep the network path tight by using VPC endpoints for all AWS API calls.

With VPC endpoints, command traffic stays inside your private network and off the public web. Finally, check that every command run writes a full record to a central log. When you combine tight tags, separate workers, and clean logs, your automation stays safe.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

How does a Temporal worker log in to AWS to run host commands?

The worker should use an IAM role attached to its host or container task. It requests temporary session keys from AWS so you never store static secrets.

What happens if an EC2 server reboots while a workflow step is running?

The host agent pauses or fails the command, and Temporal sees the timeout error. Temporal then retries the command step based on the retry rules you set up.

How can we stop Temporal history from storing sensitive command output?

Set up EC2 Systems Manager to send command output straight to a private bucket. Return only the job status and bucket path to the Temporal workflow history.

The query runs. The emails stay hidden.