Skip to main content
This guide deploys Runlayer into your AWS account. Start with the ECS overview and complete ECS prerequisites, including Runlayer credentials, AWS identity, state storage, DNS, egress, and Bedrock access. The example creates a new VPC, a public HTTPS load balancer, Aurora PostgreSQL, and ElastiCache Redis. For existing infrastructure or private access, select the networking and configuration inputs before applying. This guide explicitly selects Distribution-backed feature flags with openfeature_provider = "flagd". Obtain a Distribution reader key registered for this deployment from Runlayer before applying. The module’s application default is still WorkOS; setting only the Distribution key and URL does not switch providers.

Quick Start

1. Create the root configuration

Create a working directory and save the following as main.tf. Replace the account, hostname, parent hosted zone, state bucket, auth client ID, and company details. Pin the module release agreed with Runlayer; this example uses v49.0.0, the first release that reads the WorkOS, Sentry and Resend keys only from the provisioned tenant secret and has no auth_api_key input. See the Terraform changelog for its default app version.
Always pass both aws and aws.route53, including when DNS lives in the same account. Cross-account DNS also needs the DNS role and zone ID described in networking. For a new deployment, also set redis_engine = "valkey" (module v49.0.0 or later) so the cache runs Valkey 9.1. See Redis / ElastiCache. Terraform marks only five module inputs as required because they have no defaults. This guide also requires the catalog credential and the registered Distribution reader key. The WorkOS API key is not an input: Runlayer writes it to the provisioned tenant secret restricted/<project>-<env>-provisioned in your account before your first apply, and the plan fails until that secret exists (see Secrets management). Confirm outbound HTTPS to distribution.prod.runlayer.com before startup. Add your selected database, network, security, and optional-feature inputs to this configuration before continuing.

2. Supply credentials

Keep the AWS credential environment from prerequisites. Provide the secret inputs through your secret manager or environment. For an interactive Bash shell, these prompts avoid putting values in shell history:
Do not commit .terraform/, *.tfstate*, *.tfplan, or files containing secrets. Commit .terraform.lock.hcl after initialization.

3. Initialize, validate, and plan

Before planning, review the selected module’s provisioners. Sentry Relay is enabled by default and reads its credentials from the provisioned tenant secret at task start; no external program runs during the plan (see Sentry Relay credentials). local-exec provisioners run during resource creation/destruction, not an ordinary plan.
Review the plan’s account, region, network, public/private access, database/cache configuration, optional resources, and cost implications. Resolve errors before applying. A saved plan contains sensitive data even when terminal output redacts it. For an existing deployment with an older provider selection, review the module changelog and use terraform init -upgrade to update the lockfile before planning.

4. Apply

The module runs a separate ECS migration task and waits for it to succeed before rolling out application services. Migration logs are in anysource-backend-migration-logs-<project>-<environment>. The migration wait defaults to 30 minutes. This example sets wait_for_ecs_steady_state = true; the module default is false. Even with waiting enabled, complete the checks below: infrastructure readiness does not prove login or connector workflows work.

Verify

Run these commands from the root configuration directory, with the same AWS profile and region:
Check that there are no service lookup failures, running counts match nonzero desired counts, pending counts are zero, and the primary deployments show COMPLETED. The AWS waiter has its own timeout; a timeout requires inspecting events and logs. For a private ALB, run HTTP checks from a machine with the required private routing and DNS. Then verify the user journey:
  1. Open terraform output -raw application_url, confirm TLS is valid, and sign in through the configured SSO/WorkOS flow.
  2. Confirm the MCP catalog loads. A catalog 503 can indicate a missing API key; 401 can indicate a wrong key or catalog URL.
  3. Configure an approved test connector, connect an MCP client, and make a harmless tool call. Confirm its session/audit record appears.
  4. Exercise each feature you enabled: an agent run, ToolGuard scan, or AI Watch package discovery, as applicable. Confirm optional services and load-balancer targets are healthy too.
A reachable login page alone is not a successful deployment.

Troubleshooting

Module or image access denied

For terraform init, confirm the deployment identity can read the versioned archive in runlayer-infrastructure-modules. For CannotPullContainerError, check ECS events, ECR access to account 088332244652, and the ECR/S3 network paths. Contact Runlayer support if onboarding access is missing.

Migration task failures

If the first apply failed before root outputs were saved, substitute anysource-backend-migration-logs-ecs-production for the example configuration, or use your actual project and environment. Check the migration task’s stopped reason, database connectivity, image permissions, and the AWS CLI credentials inherited by Terraform. After correcting the cause, review a new plan before applying again. Do not disable state locking or force-unlock while another run may still own the lock. If the migration fails on lock timeout, search the log for migration_lock_timeout_snapshot. After each timed-out attempt, it lists up to 10 sessions with the oldest open transactions that hold table locks: pid, user, application name, client address, state, transaction age, wait event, and up to 10 locked tables with each lock mode (lock_count is the total). These are likely blockers at the moment the attempt failed, not a verified blocking chain, so confirm a session is still running and safe to end before you end it. If the migration’s database role lacks pg_read_all_stats, other roles’ sessions are listed first with details_hidden: true and their activity fields empty; look them up by pid as a privileged user. If the migration keeps failing on lock timeout, give it a longer wait for one deploy: if migrations starve on lock contention, set migration_escalated_lock_timeout_ms = 120000 (default 30000) in your deployment root for the upgrade. Raise it rather than migration_lock_timeout_ms, which applies to every attempt. If you previously raised migration_lock_timeout_ms (for example to 120000), restore it to 5000 when you set the escalated timeout: 20 base attempts at 120 seconds can take 40 minutes, longer than the 30-minute backend_migration_wait_timeout_seconds. Also keep migration_retry_count at or above migration_base_tier_attempts + migration_escalated_tier_attempts (default 25); a lower value stops the runner before it reaches the escalated attempts (with migration_retry_count = 1, it makes only two base attempts). Some migrations set their own lock_timeout, which overrides these inputs for that migration: its attempts fail after the migration’s timeout, sooner than the lock_timeout_ms in the migration_start log line, and raising the inputs does not help. If a migration keeps failing that way, send the failing revision and SQLSTATE (55P03 for a lock timeout) to your Runlayer Slack channel or support@runlayer.com. For a diagnosed ECS or RDS service issue, the AWS account owner can open a case in the AWS Support Center. See support boundaries.

Application not accessible

Check DNS, ACM certificate status, ALB security groups/WAF, and target health in the EC2 load balancer console. For failed ACM validation, inspect the certificate’s DomainValidationOptions and verify its exact CNAME name and value in authoritative DNS.

Login works but optional features fail

Check egress symptoms, Bedrock access, and your feature’s configuration. AgentCore behind WAF needs the private network path; ToolGuard needs working GPU bootstrap and capacity.

Next Steps

The following sections retain their existing links and point to the focused guides.

Prerequisites

See ECS prerequisites.

Private connection provisioning

See private connection provisioning. Connection configuration revision 2 is separate from module releases such as v49.0.0.

Private CA certificates

See private CA certificates.

Distribution configuration

See Distribution configuration.

Delivery details

See artifacts and versions and Updates.

Configuration options

See ECS configuration, networking, and optional features.

Secrets management

See secrets management.

Module outputs (attributes)

See module outputs.

Naming constraints

See naming constraints.

Required inputs

See the onboarding checklist and inputs reference.

Optional configuration

See configuration and optional features.

Optional services

See agents and other optional services.

Terraform module (S3)

See artifacts and versions and Updates.

Container images (ECR)

See images and versions. Image overrides are described in Updates.

Deployment

Follow Quick Start, then Verify.

Automated database setup

See the migration and startup sequence.

Overview

See the ECS overview.

Architecture

See Architecture.

Cost estimation

See capacity and cost.

Common use cases

See configuration examples.

Private enterprise deployment

See private access choices.

High availability production

See high availability configuration.

Development environment

See development configuration.

ECS vs EKS: which to choose?

See Deployment Overview.