Self-hosted CI runners on AWS EC2
Turn an EC2 instance into a Ferro runner with one User-Data script. It works on x86_64 and Graviton, On-Demand or Spot, in a public or private subnet.
Outbound HTTPS only, and no cloud credentials in Ferro
ferro-agent is a single static Linux binary for x86_64 and aarch64. In the default Relay Mode it connects out to your Ferro control plane over HTTPS (443), so the runner needs no inbound ports, and Ferro never holds AWS API credentials for a server you install yourself.
Before you start
- A Ferro account. The Free plan covers one runner; see the quickstart if you have not signed up yet.
- The AWS CLI, configured for the account and region that will hold the runner.
- A subnet with outbound internet access: a public subnet with a public IP address, or a private subnet behind a NAT gateway.
1. Register a node and copy its token
In the dashboard, open Fleet Nodes and choose Add Linux server. Name the node (for example aws-use1-c7i-01) and leave the direct URL blank to stay in Relay Mode.
Ferro shows the node's frn_... token once, together with a generated bootstrap script, and stores only the token's SHA-256 hash. Copy the token now. In the snippets below, replace https://ferro.example.com with your control plane URL and frn_YOUR_NODE_TOKEN with that token.
2. Create a security group with no inbound rules
The runner only makes outbound connections, so its security group needs no inbound rules at all, not even SSH.
# A new security group has no inbound rules and allows all outbound trafficaws ec2 create-security-group \ --group-name ferro-runner \ --description "Ferro CI runner (no inbound rules)" \ --vpc-id vpc-0123456789abcdef0Note the GroupId in the output. Builds still need outbound access for whatever they download, such as package registries and container images.
3. Save the User-Data script
Save this as ferro-ec2-userdata.sh with your control plane URL and node token filled in. On first boot it installs the prerequisites, blocks the instance metadata service for non-root users, and runs your control plane's installer, which verifies the ferro-agent release before installing it as a systemd service.
#!/usr/bin/env bashset -euo pipefail# Ferro BYO-Metal Agent — AWS EC2 Ubuntu 24.04 User-Data (Relay Mode: 0 inbound ports)export FERRO_CONTROL_PLANE="https://ferro.example.com"export FERRO_NODE_TOKEN="frn_YOUR_NODE_TOKEN"export FERRO_LABELS="linux,aws,ec2"export FERRO_MAX_CONCURRENCY="4"export DEBIAN_FRONTEND=noninteractiveapt-get update -yapt-get install -y --no-install-recommends curl ca-certificates git nftables polkitd# Block AWS EC2 IMDS (169.254.169.254) for non-root users so CI jobs cannot read user-data or IAM credsnft add table inet ferro_metadata_guardnft 'add chain inet ferro_metadata_guard output { type filter hook output priority 0; policy accept; }'nft flush chain inet ferro_metadata_guard outputnft add rule inet ferro_metadata_guard output ip daddr 169.254.169.254 meta skuid != 0 reject# Run your Control Plane's hosted verified installer (downloads & verifies SHA256SUMS + Cosign,# configures /etc/ferro/node-token via systemd LoadCredential, Polkit sandbox rules, and ferro-agent.service)curl -fsSL --proto '=https' --tlsv1.2 "${FERRO_CONTROL_PLANE}/install-agent.sh" | bashThe node token lives in User-Data
User-Data can be read through the instance metadata service and by anyone in the AWS account allowed to describe the instance. The script blocks 169.254.169.254 for non-root users so CI jobs, which run as the unprivileged ferro-job user, cannot read it or any instance role credentials. If the token is ever exposed, rotate it from Fleet Nodes.
4. Launch the instance
Replace the security group ID with yours. The command resolves the current Ubuntu 24.04 image from the public SSM parameter and requires IMDSv2.
# Launch an Ubuntu 24.04 runner with zero inbound Security Group ports (Relay Mode)# Tip: You can also save the script from Dashboard → Fleet Nodes → Add Linux server as ferro-ec2-userdata.shaws ec2 run-instances \ --image-id resolve:ssm:/aws/service/canonical/ubuntu/server/24.04/stable/current/amd64/hvm/ebs-gp3/ami-id \ --instance-type c7i.2xlarge \ --security-group-ids sg-0123456789abcdef0 \ --metadata-options "HttpTokens=required,HttpEndpoint=enabled" \ --user-data file://ferro-ec2-userdata.sh \ --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=ferro-runner-ec2-01}]'- Graviton: use an Arm instance type such as
c8g.2xlargeand changeamd64toarm64in the image parameter. The installer detects the architecture. - Spot: add
--instance-market-options MarketType=spot. A reclaimed instance ends the runs it was executing, so keep Spot for work you can run again. - Concurrency:
FERRO_MAX_CONCURRENCYin the script sets how many runs the instance takes at once. Match it to the instance size.
5. Check that the runner is online
Within a few seconds of the service starting, the node turns online in Fleet Nodes. If it does not, connect with Session Manager or the EC2 serial console and check the service:
sudo systemctl status ferro-agentsudo journalctl -u ferro-agent -n 50 --no-pagercurl -kfsS https://127.0.0.1:7420/healthStill offline? See Troubleshooting.
Good to know
- Ferro does not create or scale EC2 instances for you today. Native AWS provisioning is planned; for now each instance is a runner you register once and keep warm, which is also what keeps its dependency and build caches on local disk.
- You pay AWS for the instance and Ferro a flat monthly fee, with no per-minute charge from Ferro. If you want ephemeral runners for GitHub Actions workflows inside your AWS account instead, see Ferro vs RunsOn.
Next steps
- Install the CLI and offload a build with
ferro runfrom your terminal. - Connect the GitHub App so pushes and pull requests run on this server.
- Describe your pipeline in ferro.toml, including warm dependency caches.
- Read the security model before running code you do not trust.
- Other providers and Direct Mode are covered in Multi-Cloud Runners.