
# Deployment targets (owner view)

A deployment target is where app compute runs, such as one node in your own AWS VPC. **Default for new apps** on **Infrastructure** > **Targets** chooses where new apps run. Success is **Healthy** with "· default" on the target's row.

An owner adds an AWS target without giving Agent Cloud an AWS credential. The app's Postgres stays in Agent Cloud's account.

## Do it in the console

Only organization owners can change targets; builders see the page "View only".

**Add an AWS target**

1. In the left menu, open **Infrastructure**, pick the **Targets** tab, then click **Add AWS target**.
2. Fill in **Name**, **AWS account ID**, **Region**, **Node size**, **VPC**, **Private subnets**, **VPC CIDR** and **Internal domain**. Open **Network options** only for **Host pattern**, **Shared VPC**, **Internal ALB certificate** or **ALB sources**.
3. Click **Add target**.
4. Open the new row's **Manage**, click **Download infra-agent.md**, and hand the file to whoever runs that AWS account, or their coding agent.

The target shows **Waiting for install** until its runner registers, then **Healthy**.

**Make it the default** in **Default for new apps**, then **Save**; the first choice, **Agent Cloud**, undoes it. Everything else is under the row's **Manage** ([Reference](#reference)).

## How it works

The default applies only to apps created after you save it, by an agent that joined your organization; others run on Agent Cloud. An app never moves between targets. **Default for new apps** lists targets still **Waiting for install**; don't pick one until it's **Healthy**, or new apps land on a node that can't run them yet.

**The runbook**, `infra-agent-<target id>.md`, holds this target's CloudFormation template, checked bash steps and a doctor ([Installing with infra-agent.md](/docs/targets/installing-with-infra-agent-md.md)). Its registration code works once, within 24 hours, and each download voids the last one, so treat the file as a secret until the target is **Healthy**.

| Topic | How it works |
|---|---|
| Health | The runner reports every minute; after 3 silent minutes the target turns **Unhealthy**, with a reason such as "k3s isn't ready on the node." Anything that needs you shows "Needs attention: open Manage for what and how." |
| Upgrades | The runner moves itself to Agent Cloud's current version when no task is running. **Hold upgrades** stops that until **Allow upgrades**: use it for a change freeze, and expect to fall behind fixes ([self-upgrade](/docs/targets/manifests-and-updates.md#runner-self-upgrade-and-the-stack-update-policy)). |
| Manifests | Agent Cloud never changes the target's Kubernetes objects. When they fall behind, **Manage** lists what's missing, the current manifests' sha256 and update steps, and offers **Download manifests.yaml** ([Manifests and updates](/docs/targets/manifests-and-updates.md)). |
| Caps | You cap the `cpu` and `memory` one app may ask for, web and worker instances together. A release over the cap, or too big for the node, fails before it builds. |
| Node size | A stand-in until the node reports what it has. The real node is sized in its CloudFormation stack, so changing it here adds no room ([Sizing and capacity](/docs/targets/sizing-and-capacity.md)). |
| Outbound hosts | Apps here reach a public host only once you approve it for that app; rehearsals never do. A ship naming new hosts in `[production] egress_allow` asks you under **Outbound hosts** and **Needs you**. |

Every change lands in Activity, for example "added the deployment target" or "approved outbound".

## Removing a target

Removal is refused while any app on the target is live. Delete the apps first, while the runner still works: once it's revoked, nothing of Agent Cloud's can remove anything from the node.

1. **Delete each app on the target** from its settings page (owner). Its runner removes the app's namespace, everything in it and its routes.
2. **Manage** > **Remove this target**, type the target's name, then **Remove target** (owner). Success reads "Removed <target>: its runner is revoked and new apps no longer go there."
3. **Delete the CloudFormation stack** (your infra team): the node, IAM role, security groups, endpoints and ALBs. Agent Cloud has no credentials to do it.

```bash
aws cloudformation delete-stack --stack-name "$STACK"
aws cloudformation wait stack-delete-complete --stack-name "$STACK"
```

A public ALB's log bucket (`AlbLogs`, `aws-waf-logs-agc-…`) has `DeletionPolicy: Retain` and stays until you delete it. To hand step 3 to your infra team's agent:

```text
We've removed our Agent Cloud target in the console. In our AWS account, show me the CloudFormation
stack agent-cloud-<target id> and its resources, then delete the stack. Afterwards, tell me whether an
S3 bucket named aws-waf-logs-agc-… was left behind and how much it holds, but don't delete it.
```

You'll see the stack's resources, the delete, and whether a retained log bucket needs a decision.

If the runner was already revoked when an app was deleted, Agent Cloud finishes the deletion. The app's **Deleted** row records the command your infra team runs, such as `on_node "k3s kubectl delete namespace app-camp-bookings"`. A runner that's merely down keeps the removal waiting and finishes it when it's back.

Removal, in one transaction, revokes the runners (their tokens stop at once), drops unused registration codes, deletes any certificate Agent Cloud held, clears the default and marks the target removed (`target.removed`). It's refused by every target route but kept, so history and receipts keep its name. Apps awaiting their 30-day purge don't block removal, but an app that ran there can't be restored.

**Revoke runner** is the lighter option, for a suspected leak or a node rebuild: the target, settings and app records stay, and a fresh `infra-agent.md` registers it again.

## Reference

**Manage controls**

Besides **Download infra-agent.md** (a fresh runbook and code), **Download manifests.yaml** (only when objects are behind), **Hold upgrades** / **Allow upgrades**, **Revoke runner** (once a runner has registered) and **Remove this target**, **Manage** has:

| Control | What it does |
|---|---|
| **App CPU cap**, **App memory cap**, **Node size**, **Save** | What one app may ask for, and the node releases are measured against |
| **Outbound hosts**: **Approve**, **Decline**, **Revoke** | Decide a host a release asks for, or take one back (within 10 seconds) |
| **Approve a host** | Approves a host for one app before it ships (443 only) |
| **API gateway**: **Accept plain HTTP** / **Withdraw plain HTTP** | Lets the API gateway serve [HTTP API connections](/docs/owners/connections.md) over plain HTTP on a single-node target until verified TLS is ready |
| **Turn off** / **Turn on** | Stops (or restarts) every app here reaching its approved hosts, within 10 seconds; approvals are kept, and while off a ship naming a host is refused |

The targets table shows each **Target** ("· default" on the default), **Where** (account · region · VPC, "(shared)" for a shared VPC), **Capacity** (node size and what the node reports for apps), **Apps** and **Health**.

## Errors

Failed console actions show "That didn’t go through" with one of these messages:

| Message | Fix |
|---|---|
| "Only owners manage the organization" | Ask one of the owners it names. |
| "Check the target: …" | Fix each listed field and click **Add target** again. |
| "<name> still runs <apps>. Delete it first; …" (409) | Delete those apps, then remove the target. |
| "Type the target’s name, <name>, to remove it." (400) | Type it exactly. |
| "Nothing to apply yet" | Upgrades are held and the runner's image is unknown: wait a heartbeat, or allow upgrades. |

Codes from agc and the node (`ship.over_cap`, `ship.no_room`, `egress.not_approved`, `target.code_refused`, `app.target_removed`, `delete.by_hand`), with exit and fix: [Error code catalog](/docs/reference/error-code-catalog.md).

## Limits

A target name is at most 60 characters. Node sizes and cap ranges: [Sizing and capacity](/docs/targets/sizing-and-capacity.md); one runner per target: [Architecture of a private target](/docs/targets/architecture-of-a-private-target.md#registration-and-identity).

## Agent notes

- After a target is removed, `agc init --join` in that organization puts new apps on Agent Cloud again.
- Targets are an owner's, in the console; relay the owner's name from the error rather than looking for an `agc` command.
- To put an existing app on another target, a person deletes it and an agent creates it again there.

## Related

- [Where apps run (targets)](/docs/concepts/where-apps-run.md)
- [Architecture of a private target](/docs/targets/architecture-of-a-private-target.md)
- [Installing with infra-agent.md](/docs/targets/installing-with-infra-agent-md.md)
- [Manifests and updates](/docs/targets/manifests-and-updates.md)
- [Sizing and capacity](/docs/targets/sizing-and-capacity.md)
- [Deleting and restoring an app](/docs/ship/deleting-and-restoring-an-app.md)

<!-- feedback:start -->
---
Wrong, outdated or unclear? Run `agc feedback docs "owners/deployment-targets: <what is wrong>" --body <file>` with the sentence quoted in the file. No code or app data is sent.
<!-- feedback:end -->
