# AWS permissions and resources

> For the complete documentation index, see [llms.txt](https://docs.ringleader.dev/llms.txt).


> What AWS onboarding creates in your account, what Ringleader may do there, what your account checks and which values you hand back.


Onboarding AWS creates an IAM OIDC identity provider, an IAM role with a permission
policy, and optionally a network, in an AWS account you own. This page lists those
resources, the permissions the role holds and the values you send back to Ringleader. To run the
setup, follow [Onboard AWS](https://docs.ringleader.dev/guides/onboard-aws/).

## Resources onboarding creates

*Diagram: Ringleader signs a short-lived OIDC token whose issuer, subject and audience name your organization, and presents it to an IAM OIDC identity provider in your own AWS account. That provider accepts only your organization's issuer, audience and subject, and sts:AssumeRoleWithWebIdentity reaches the ringleader-workstations IAM role you create, whose base policy allows the EC2 instance lifecycle. That role creates, manages and terminates the workstation EC2 instances in your account.*

```mermaid
flowchart TB
  CP["<b>Ringleader control plane</b><br/>signs a short-lived OIDC token<br/>iss = &lt;issuer&gt;/org/&lt;your-org-id&gt;<br/>sub = org:&lt;your-org-id&gt;<br/>aud = &lt;issuer&gt;/org/&lt;your-org-id&gt;/aws"]

  subgraph account["Your AWS account"]
    direction TB
    IdP["<b>IAM OIDC identity provider</b><br/>admits only the per-org issuer;<br/>the trust pins BOTH aud AND sub"]
    Role["<b>ringleader-workstations</b><br/>the IAM role you create<br/>base policy: EC2 instance lifecycle"]
    EC2["<b>Workstation EC2 instances</b><br/>created, managed and terminated"]
  end

  CP -- "presents the token" --> IdP
  IdP -- "sts:AssumeRoleWithWebIdentity" --> Role
  Role --> EC2
```


Onboarding creates three things in your account, all visible in the AWS console afterwards,
plus an optional fourth:

- An **IAM OIDC identity provider**. This is how AWS confirms that a request really comes from
  Ringleader and is meant for your organization, without Ringleader ever holding an access key.
- An **IAM role** called `ringleader-workstations`. This is the role Ringleader assumes when it
  creates or terminates an instance.
- A **permission policy** on that role. It lets the role create, start, stop and terminate EC2
  instances and read what it needs to do that. The features under [Setup switches](#setup-switches)
  add more, and runtime identities, which are on by default, add IAM permissions.
- Optionally, a **network** for the workstations: a VPC, a subnet, a NAT gateway, and two
  security groups. Both setup paths create it unless you turn it off (`create_network = false`
  or `CREATE_NETWORK=false`).

## Rights and limits in your account

The base policy lets Ringleader manage EC2 instances and nothing else. The role Ringleader signs in
as has no billing access and no account admin. It gets IAM permissions only from runtime identities,
which are on by default and can reach the whole account, as [Setup switches](#setup-switches)
describes.
[Cloud accounts](https://docs.ringleader.dev/cloud-accounts/) says what Ringleader gets and what it never
gets. The base policy is exactly:

- thirteen read-only `ec2:Describe` actions (instances, instance status, instance types, instance
  type offerings, images, subnets, security groups, VPCs, volumes, volume modifications, network
  interfaces, tags and availability zones), named one by one rather than granted as a wildcard, on
  `*` because none of these thirteen supports resource-level scoping. Ringleader reads the instance
  types in your region and which availability zones offer each one, so a person creating a
  workstation picks an instance type its availability zone offers,
- `ec2:DescribeInstanceAttribute`, also on `*`, in a statement of its own so that it takes the
  same optional region bound as the actions below. It is the one read here that returns content
  rather than shape. Asked for the `userData` attribute, it returns an instance's whole boot
  payload. That is how Ringleader checks that what it wrote to a workstation carries no
  credential,
- `ec2:RunInstances` / `TerminateInstances` / `StartInstances` / `StopInstances` /
  `ModifyInstanceAttribute` / `ModifyVolume` / `ModifyInstanceCpuOptions` / `CreateTags` /
  `DeleteTags`, the instance lifecycle, growing a workstation's root volume, turning nested
  virtualization on or off for an existing workstation, and tag upkeep, optionally bounded to one
  region with an `aws:RequestedRegion` condition. EC2 changes nested virtualization only on a
  stopped instance, so Ringleader stops the workstation, makes the change and starts it again,
- `ssm:GetParameters` / `GetParameter` on `arn:aws:ssm:*::parameter/aws/service/*`, the
  AWS-owned public AMI parameters that an `image.distribution` / `image.version` resolves to at
  launch.

## Setup switches

Three features are on by default and add to the base policy. Each has a switch that turns it
off. Nothing else changes when you do.

| Feature | What it adds | Turn it off with |
|---|---|---|
| Runtime identities | Creating, tagging and deleting IAM roles and instance profiles under one IAM path, attaching any managed policy to those roles, passing them to EC2 with `iam:PassRole`, listing every role and instance profile in the account, and putting an instance profile on an instance | `enable_workstation_identities = false` (Terraform) or the `EnableWorkstationIdentities` stack parameter (CloudFormation) |
| Egress control | Security-group and routing actions, listed under [Egress control permissions](#egress-control-permissions) | `enable_egress_control = false` (Terraform) or `EGRESS_CONTROL=false` (CloudFormation, which passes it as the `EnableEgressControl` parameter) |
| Artifact storage | S3 access to buckets named `ringleader-*`, or to one bucket you name | `enable_artifact_storage = false` (Terraform) or the `EnableArtifactStorage` stack parameter (CloudFormation) |

[Cloud runtime identities](https://docs.ringleader.dev/cloud-accounts/cloud-identities/runtime-identities/)
and [Storage buckets](https://docs.ringleader.dev/cloud-accounts/storage-buckets/) explain the first and
third. [Outbound restrictions](https://docs.ringleader.dev/security/outbound/outbound-restrictions/)
explains the second.

The IAM path for runtime identities is `/ringleader-workstations/` on Terraform and `/ringleader/`
on CloudFormation, unless you set your own (`workstation_identity_path` or
`WORKSTATION_IDENTITY_PATH`). Roles you created under that path by hand are within reach too.

<div class="callout callout-warning">
  <p class="callout-title">Runtime identities can reach the whole account</p>
  <div class="callout-body">
    Nothing limits which managed policy Ringleader attaches to a role it creates, <code>AdministratorAccess</code>
included. So with runtime identities on, Ringleader can give a workstation access to anything in
the account. Use an AWS account dedicated to Ringleader, or turn runtime identities off.
  </div>
</div>


## Checks your account makes

When Ringleader asks to act in your account, AWS checks three things about the token it
presents. All three are built from the two values Ringleader gave you, and the module and the
stack configure them for you.

| What AWS checks | Value | Where it is configured |
|---|---|---|
| Who signed the token | `<issuer-url>/org/<org-id>` | the IAM OIDC provider's URL |
| Which organization it speaks for | `org:<org-id>` | the role trust policy's `sub` condition |
| Which cloud it may be used against | `<issuer-url>/org/<org-id>/aws` | the provider's client-id list, and the role trust's `aud` condition |

The role checks all three, not just who signed the token. Checking only that would accept any
token Ringleader signs, including one it signed for another customer.

If AWS turns Ringleader away, compare these three against what was created.
[Fix a sign-in that your cloud refuses](https://docs.ringleader.dev/cloud-accounts/keyless-access/#fix-a-sign-in-that-your-cloud-refuses)
says what to look for.

## Egress control permissions

Egress control is on by default. It lets Ringleader write the security group that admits SSH
to your workstations, so with it turned off they are reachable only through a rule of your own.
A workstation with no egress policy still has no limit on where it connects. It adds these
actions:

| Action | For |
|---|---|
| `ec2:CreateSecurityGroup`, `ec2:DeleteSecurityGroup` | one group per distinct egress policy, and the group that admits SSH to your workstations |
| `ec2:AuthorizeSecurityGroupEgress`, `ec2:RevokeSecurityGroupEgress` | keep a policy group's rules in step with the workstation's configuration, and remove the allow-all outbound rule AWS puts on a new SSH group |
| `ec2:AuthorizeSecurityGroupIngress`, `ec2:RevokeSecurityGroupIngress` | the SSH rules on the SSH group, and the edge instance's own group, which has to admit workstation traffic |
| `ec2:UpdateSecurityGroupRuleDescriptionsIngress` | mark a rule on that group as Ringleader's own, so it revokes only the rules it wrote. It selects a rule that already exists and replaces its description text, expressing no protocol, port or address of its own, so it cannot add, remove or widen a rule |
| `ec2:ModifyNetworkInterfaceAttribute` | move a running workstation onto the group for its policy, and attach the SSH group. Also clear the source and destination check on the edge instance's own interface, without which AWS drops every packet it forwards |
| `ec2:CreateRouteTable`, `ec2:DeleteRouteTable`, `ec2:CreateRoute`, `ec2:ReplaceRoute`, `ec2:DeleteRoute`, `ec2:AssociateRouteTable`, `ec2:DisassociateRouteTable`, `ec2:CreateSubnet`, `ec2:DeleteSubnet` | route traffic to the edge instance, for a policy that names hostnames. An AWS route table attaches per subnet, so routing is per subnet rather than per workstation |
| `ec2:DescribeSecurityGroupRules`, `ec2:DescribeRouteTables` | read back the rules and routes Ringleader wrote, so a rule or route someone else changed is reported rather than silently overwritten |
| `ec2:AllocateAddress`, `ec2:ReleaseAddress`, `ec2:AssociateAddress`, `ec2:DisassociateAddress`, `ec2:DescribeAddresses` | reserving a fixed public address for the edge instance's VM. Ringleader does not use them today: the edge instance's public address is not reserved, and it changes when Ringleader replaces the instance |

The security-group, route-table and subnet writes are limited to your workstations' VPC. The two
reads and the five Elastic IP actions are limited to your region instead. EC2's `Describe`
actions take no resource-level scoping, and an Elastic IP belongs to no VPC when it is
allocated. The three creates are held to your VPC by resource name rather than by a condition,
because AWS authorizes a create against the object it makes.

Where no VPC is known, the VPC bound falls away and the region bound is all that is left. Both
setup paths set a region. If you reference the Terraform module from your own configuration,
set `allowed_regions` to bound it. It is empty by default, which places no region condition
and leaves the whole account as the boundary.

## Security groups for workstations

With egress control on, the network the module creates has two security groups, and you send
both ids back to Ringleader. Whoever administers Ringleader gives each workstation one of them,
depending on whether it has an egress policy.

| You send back | It is for | Lets in | Lets out |
|---|---|---|---|
| `security_group_id` / `SecurityGroupId` | a workstation with **no** egress policy | TCP 22 and 2222 from your addresses | everything |
| `inbound_only_security_group_id` / `InboundOnlySecurityGroupId` | a workstation **with** an egress policy | the same | nothing |

To choose between them, follow
[Choose the security group for workstations](https://docs.ringleader.dev/guides/onboard-aws/#choose-the-security-group-for-workstations).
[Enforcement points](https://docs.ringleader.dev/security/outbound/enforcement/) explains why there are
two.

## Values you hand back

| Value | Where it lands |
|---|---|
| **role ARN** (`arn:aws:iam::<account-id>:role/ringleader-workstations`) | [CloudAccount](https://docs.ringleader.dev/reference/resources/cloudaccount/) `spec.aws.targetRoleArn` |
| **region** | [CloudIdentity](https://docs.ringleader.dev/reference/resources/cloudidentity/) `providerConfig.aws.region` |
| **subnet id** (only if you created the network) | `providerConfig.aws.subnetId` |
| **security group id** (only if you created the network) | `providerConfig.aws.securityGroupIds` |
| **inbound-only security group id** (only with the network and egress control) | `providerConfig.aws.securityGroupIds`, for a workstation with an egress policy, as [Outbound restrictions](https://docs.ringleader.dev/security/outbound/outbound-restrictions/) explains; see [Security groups for workstations](#security-groups-for-workstations) |
| **IAM path for runtime identities** (only if you use runtime identities) | CloudAccount `spec.aws.workstationIdentityPath` |

`terraform output handoff` prints all of these together except the IAM path, and `deploy.sh`
prints the same ones when it finishes. The IAM path is the one that
[Setup switches](#setup-switches) names for the tool you used.

When you write the CloudIdentity from these values, pick an x86-64 instance type. The image
aliases (`ubuntu-24.04`, `debian-12`, `amazonlinux-2023`, …) resolve x86-64 AMIs, so an arm64
(Graviton) instance type will not match them. The default instance type, `t3.medium`, is
x86-64, and so is an `m6i.*` or `c6i.*` type.

## Next steps

- [Onboard AWS](https://docs.ringleader.dev/guides/onboard-aws/): run the setup and send the values back.
- [CloudAccount](https://docs.ringleader.dev/reference/resources/cloudaccount/): the object that records which IAM
  role to assume in your account.
- [CloudIdentity](https://docs.ringleader.dev/reference/resources/cloudidentity/): how workstations in your account
  are built.
- [Provider images and keys](https://docs.ringleader.dev/reference/providers/images-keys/): the full
  `providerConfig.aws` field set.

