Machines
You can use the Machines resource to create, stop, start, update, and delete Fly Machines. Fly Machines are fast-launching VMs on Fly.io. The Machine resource is the configuration and state for a Machine.
Machine properties
Property | Description |
---|---|
id |
A stable identifier for the Machine. |
name |
Unique name for the Machine. If omitted, one is generated for you. |
state |
The state of the Machine. |
region |
The region where the Machine resides, or the target region for the Machine on create. If omitted, the Machine is placed in the same region as your WireGuard peer connection (somewhere near you). |
instance_id |
An identifier for the current running/ready version of the Machine. Every Update request potentially changes the instance_id . |
private_ip |
The 6PN IPv6 address of the Machine, which is where it’s reachable to other Machines in the same organization and network_id . |
config |
See the config object properties section. Object that defines the Machine configuration. |
checks |
Object that provides the status of any configured health checks. |
image_ref |
Object that defines the image details. |
created_at |
Date and time the Machine was created. |
updated_at |
Date and time the Machine was last updated. |
events |
Array of objects that provide log of what’s happened with this Machine. |
nonce |
The Machines lease nonce, if this Machine is currently leased. Also returned on Machine create if lease_ttl is provided. |
List Machines
List all the Machines for an app.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App to list Machines for.
-
- Query parameters
-
-
include_deleted
: Boolean -
If true, include deleted Machines in the response.
-
region
: String -
Filter by region. For example, to return only Machines in the
yyz
region:GET /v1/apps/my-app-name/machines?region=yyz
-
metadata.{key}
: String -
Filter by metadata key-value pair. For example, to return only Machines with metadata item
"foo": "bar"
:GET /v1/apps/my-app-name/machines?metadata.foo=bar
-
- Responses
-
-
200
: -
OK
-
curl -i -X GET \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines"
[
{
"id": "a5c5de9ce64ca12",
"name": "aged-wind-2649",
"state": "started",
"region": "ord",
"image_ref": {
"registry": "registry-1.docker.io",
"repository": "rebelthor/sleep",
"tag": "latest",
"digest": "sha256:597c3e12f830132be2aa69b4c0deccb0657ea4253e6d59c6f38e41e9f69a0add"
},
"instance_id": "1RREBN3T5K95DK9IVP4XHTTPEY2",
"private_ip": "fdaa:0:18:a7b:196:e274:9ce1:2",
"created_at": "2023-10-31T02:30:10Z",
"updated_at": "2023-10-31T02:35:26Z",
"config": { /* Fly Machine Config */ },
"events": [
{
"type": "start",
"status": "started",
"source": "flyd",
"timestamp": 1698719726615
},
{
"type": "launch",
"status": "created",
"source": "user",
"timestamp": 1698719723203
}
]
},
{
"id": "9c487adb2596113",
"name": "summer-sun-916",
"state": "started",
"region": "ord",
"image_ref": {
"registry": "registry.fly.io",
"repository": "teamcoco",
"digest": "sha256:5615ef423504d56ae345ccff9db54796d589965da953297f5785042df0628452"
},
...
}
]
Create a Machine
Given the name of a Fly App, create a Fly Machine, given the URI of a container image, in some region (or, by default, the region closest to you) on Fly.io’s platform. If successful, that Machine will boot up by default. Create a Machine without booting it by setting skip_launch
.
You can configure the Machine characteristics, like its CPU and memory. You can also allow connections from the internet through the Fly Proxy by creating a Machine with services. Learn more about this behavior in the networking section.
Important: This request can fail, and you’re responsible for handling that failure. If you ask for a large Machine, or a Machine in a region we happen to be at capacity for, you might need to retry the request, or to fall back to another region. If you’re working directly with the Machines API, you’re taking some responsibility for your own orchestration!
The only required parameter in the body is image
in the config
object.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App to create a Machine for.
-
- Responses
-
-
200
: -
OK
-
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines" \\
-d '{
"config": {
"init": {
"exec": [
"/bin/sleep",
"inf"
]
},
"image": "registry-1.docker.io/library/ubuntu:latest",
"auto_destroy": true,
"restart": {
"policy": "always"
},
"guest": {
"cpu_kind": "shared",
"cpus": 1,
"memory_mb": 256
}
}
}'
{
"id": "1857156b526dd8",
"name": "aged-thunder-7371",
"state": "created",
"region": "ord",
"image_ref": {
"registry": "registry-1.docker.io",
"repository": "library/ubuntu",
"tag": "latest",
"digest": "sha256:c9cf959fd83770dfdefd8fb42cfef0761432af36a764c077aed54bbc5bb25368",
"labels": {
"org.opencontainers.image.ref.name": "ubuntu",
"org.opencontainers.image.version": "22.04"
}
},
"instance_id": "01HEPA330HZ37A78TK080NAK1M",
"private_ip": "fdaa:ff:ff:a7b:195:e229:8038:2",
"created_at": "2023-11-08T01:52:30Z",
"updated_at": "2023-11-08T01:52:30Z",
"config": {
"init": {
"exec": [
"/bin/sleep",
"inf"
]
},
"image": "registry-1.docker.io/library/ubuntu:latest",
"auto_destroy": true,
"restart": {
"policy": "always"
},
"guest": {
"cpu_kind": "shared",
"cpus": 1,
"memory_mb": 256
},
"dns": {}
},
"events": [
{
"type": "launch",
"status": "created",
"source": "user",
"timestamp": 1699408350300
}
]
}
Create a Machine with services
Create a Machine with services defined on app. Learn more about services and networking.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App to create a Machine for.
-
- Responses
-
-
200
: -
OK
-
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines" \\
-d '{
"name": "my-app-name",
"config": {
"image": "flyio/fastify-functions",
"env": {
"APP_ENV": "production"
},
"services": [
{
"ports": [
{
"port": 443,
"handlers": [
"tls",
"http"
]
},
{
"port": 80,
"handlers": [
"http"
]
}
],
"protocol": "tcp",
"internal_port": 8080
}
],
"checks": {
"httpget": {
"type": "http",
"port": 8080,
"method": "GET",
"path": "/",
"interval": "15s",
"timeout": "10s"
}
}
}
}'
{
"id": "1857156b526dd8",
"name": "aged-thunder-7371",
"state": "created",
"region": "ord",
"image_ref": {
"registry": "registry-1.docker.io",
"repository": "library/ubuntu",
"tag": "latest",
"digest": "sha256:c9cf959fd83770dfdefd8fb42cfef0761432af36a764c077aed54bbc5bb25368",
"labels": {
"org.opencontainers.image.ref.name": "ubuntu",
"org.opencontainers.image.version": "22.04"
}
},
"instance_id": "01HEPA330HZ37A78TK080NAK1M",
"private_ip": "fdaa:ff:ff:a7b:195:e229:8038:2",
"created_at": "2023-11-08T01:52:30Z",
"updated_at": "2023-11-08T01:52:30Z",
"config": {
"init": {
"exec": [
"/bin/sleep",
"inf"
]
},
"image": "registry-1.docker.io/library/ubuntu:latest",
"auto_destroy": true,
"restart": {
"policy": "always"
},
"guest": {
"cpu_kind": "shared",
"cpus": 1,
"memory_mb": 256
},
"dns": {}
},
"events": [
{
"type": "launch",
"status": "created",
"source": "user",
"timestamp": 1699408350300
}
]
}
Wait for a Machine to reach a specified state
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to wait for.
-
- Query parameters
-
-
instance_id
: string -
Filter for a specific Machine
instance_id
(version). Required when waiting for Machine to be instopped
state. -
timeout
: integer -
The time, in seconds, to wait for the Machine to enter the specified state. Default is 60.
-
state
: string enum -
The Machine state to wait for. Values are:
started
,stopped
,suspended
, ordestroyed
. Default isstarted
.
-
- Responses
-
-
200
: -
OK
-
400
: -
Bad Request
-
408
: -
Request Timeout
-
curl -i -X GET \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/73d8d46dbee589/wait?state=stopped&instance_id=01HMVXC16ED6SHK9452AF029Y7"
{
"ok": true
}
Get a Machine
Given the name of a Fly App and a Fly Machine ID, retrieve the details of that Machine.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to get.
-
curl -i -X GET \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/73d8d46dbee589"
{
"id": "a5c5de9ce64ca12",
"name": "aged-wind-2649",
"state": "started",
"region": "ord",
"image_ref": {
"registry": "registry-1.docker.io",
"repository": "rebelthor/sleep",
"tag": "latest",
"digest": "sha256:597c3e12f830132be2aa69b4c0deccb0657ea4253e6d59c6f38e41e9f69a0add"
},
"instance_id": "1RREBN3T5K95DK9IVP4XHTTPEY2",
"private_ip": "fdaa:0:18:a7b:196:e274:9ce1:2",
"created_at": "2023-10-31T02:30:10Z",
"updated_at": "2023-10-31T02:35:26Z",
"config": { /* Fly Machine Config */ },
"events": [
{
"type": "start",
"status": "started",
"source": "flyd",
"timestamp": 1698719726615
},
{
"type": "launch",
"status": "created",
"source": "user",
"timestamp": 1698719723203
}
]
}
Update a Machine
Given the name of a Fly App and a Fly Machine ID, update the configuration of the Machine. If the Machine is running and the request is successful, it will reboot; if the Machine isn’t running, and you don’t want it to start up, set skip_launch
.
This is, in particular, how you would update the running image of a Machine (when you need to deploy new code), or roll back to a previous Machine release. It’s also how you’d vertically scale an application.
Important: This request can fail, and you’re responsible for handling that failure. If you ask for a large Machine, or a Machine in a region we happen to be at capacity for, you might need to retry the request, or to fall back to another region. If you’re working directly with the Machines API, you’re taking some responsibility for your own orchestration!
region
and name
are immutable and cannot be updated.
Note: You need to specify the entire Machine config to update a Machine; we don’t support partial updates. You can get the Machine you want to update, copy and modify the config
and include it in the body of the update request. Refer to the Machine config
object properties section for property descriptions.
- Request headers
-
-
fly-machine-lease-nonce
: string -
The Machine lease nonce, a random value we provide that indicates that you currently hold the lease on this Machine. If the Machine is leased, and you don’t provide this header, the request to update the Machine will fail.
-
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to update.
-
- Responses
-
-
200
: -
OK
-
400
: -
Bad Request
-
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/73d8d46dbee589" \\
-d '{
"config": {
"image": "flyio/fastify-functions",
"guest": {
"memory_mb": 512,
"cpus": 2,
"cpu_kind": "shared"
},
"env": {
"APP_ENV": "production"
},
"services": [
{
"ports": [
{
"port": 443,
"handlers": [
"tls",
"http"
]
},
{
"port": 80,
"handlers": [
"http"
]
}
],
"protocol": "tcp",
"internal_port": 8080
}
]
}
}'
{
"id": "73d8d46dbee589",
"name": "lingering-moon-48",
"state": "starting",
"region": "cdg",
"instance_id": "01G3SHPYE8XZ58GD4XRRF9CCKC",
"private_ip": "fdaa:0:3ec2:a7b:5adc:6068:5b85:2",
"config": {
"env": null,
"init": {
"exec": null,
"entrypoint": null,
"cmd": null,
"tty": false
},
"image": "flyio/fastify-functions",
"metadata": null,
"restart": {
"policy": ""
},
"guest": {
"cpu_kind": "",
"cpus": 2,
"memory_mb": 512
}
},
"image_ref": {
"registry": "registry-1.docker.io",
"repository": "flyio/fastify-functions",
"tag": "latest",
"digest": "sha256:e15c11a07e1abbc50e252ac392a908140b199190ab08963b3b5dffc2e813d1e8",
"labels": {
}
},
"created_at": "2022-05-23T22:48:21Z"
}
Stop a Machine
Stopping a started Machine will shut down the Machine, but not destroy it. The Machine can be started again with machines/<machine_id>/start
.
Stopping a suspended Machine will invalidate its snapshot, forcing it to perform a cold boot the next time it is started.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to stop.
-
- Responses
-
-
200
: -
OK
-
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/73d8d46dbee589/stop"
{
"ok": true
}
Suspend a Machine
Suspending a Machine pauses the Machine and takes a snapshot of its state, including its memory. The next start operation will attempt (but is not guaranteed) to resume the Machine from the snapshot, rather than performing a cold boot.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to suspend.
-
- Responses
-
-
200
: -
OK
-
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/73d8d46dbee589/suspend"
{
"ok": true
}
Start a Machine
Start a Machine.
Stopped Machines that are restarted are completely reset to their original state so that they start clean on the next run.
Suspended Machines that are started attempt to resume from the snapshot taken when they were suspended. If this is not possible, then they will perform a cold boot, as though starting from the stopped state; however, their root file systems will not be reset.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to start.
-
- Responses
-
-
200
: -
OK
-
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/73d8d46dbee589/start"
{
"previous_state": "stopped",
"migrated": false,
"new_host": ""
}
Delete a Machine permanently
Delete a Machine. This action cannot be undone.
Given the name of a Fly App and the Machine ID of a Fly Machine, delete the Machine.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to delete.
-
- Query parameters
-
-
force
: boolean -
Force stop the Machine if running.
-
curl -i -X DELETE \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/24d896dec64879?force=true"
{
"ok": true
}
Create a Machine lease
Create a lease for a specific Machine within an app using the details provided in the request body. Machine leases can be used to obtain an exclusive lock on modifying a Machine.
The Machine lease nonce is a random value we provide that indicates that you currently hold the lease on a Machine. To use the provided nonce from the create or get lease response, add the fly-machine-lease-nonce
header to all subsequent API calls to the Machine for the duration of the lease. See Release a Machine lease.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to create a lease for.
-
- Responses
-
-
201
: -
Created
-
409
: -
Conflict
-
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/3d8d413b29d089/lease" \\
-d '{
"description": "",
"ttl": 500
}'
{
"status": "success",
"data": {
"nonce": "5c35f65c9f95",
"expires_at": 1708569778,
"owner": "hello@fly.io",
"description": "",
"version": "01HQ73A7BFFDF1B6WMGHFZZ4E7"
}
}
Get a Machine lease
Retrieve the current lease of a specific Machine within an app. Machine leases can be used to obtain an exclusive lock on modifying a Machine.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to retrieve a lease for.
-
- Responses
-
-
200
: -
OK
-
404
: -
Not Found
-
curl -i -X GET \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/3d8d413b29d089/lease"
{
"status": "success",
"data": {
"nonce": "5c35f65c9f95",
"expires_at": 1708569778,
"owner": "hello@fly.io",
"description": "",
"version": "01HQ73A7BFFDF1B6WMGHFZZ4E7"
}
}
Release a Machine lease
Release the lease of a specific Machine within an app. Machine leases can be used to obtain an exclusive lock on modifying a Machine.
- Request headers
-
-
fly-machine-lease-nonce
: string -
Required to release a lease. The Machine lease nonce, a random value provided in the response when you get or create a lease.
-
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to release a lease for.
-
- Responses
-
-
200
: -
OK
-
400
: -
Bad Request
-
curl -i -X DELETE \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" -H "fly-machine-lease-nonce: fed368b018e9" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/3d8d413b29d089/lease"
{
"status": "success",
"data": {
"ok": true
}
}
Route requests away from or back to a Machine
Given the name of a Fly App and the Machine ID of a Fly Machine, instruct the Fly Proxy not to send requests to a Machine or to start sending requests again to a previously cordoned Machine.
You can also do this with a fresh Machine, all in one shot, using the skip_service_registration
request field of a Machine Create request.
This is useful for bluegreen deployments: boot up a new, “green”, cordoned Machine running the new release (using skip_service_registration
), make sure it’s healthy, then uncordon it and tear down the old, “blue” Machine.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to cordon or uncordon.
-
- Responses
-
-
200
: -
OK
-
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/73d8d46dbee589/cordon"
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/73d8d46dbee589/uncordon"
{
"ok": true
}
Get a Machine’s metadata
Get the metadata defined in a specific Machine’s config.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to get the metadata for.
-
- Responses
-
-
200
: -
OK
-
curl -i -X GET \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/9080e339b57798/metadata"
{
"fly_flyctl_version":"0.2.8",
"fly_platform_version":"v2",
"fly_process_group":"app",
"fly_release_id":"Nj7oGMlVVpZ7JToybJoXLLjMl",
"fly_release_version":"63"
}
Add or update Machine metadata
Add or update a metadata key-value pair on a specific Machine’s config.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to update the metadata for.
-
key
: string required -
A key for the metadata key-value pair to add or replace. Provide the value in the request body.
-
- Responses
-
-
204
: -
No content
-
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/9080e339b57798/metadata/foo-key" \\
-d '{
"value":"bar"
}'
no body
Delete Machine metadata
Delete a metadata key-value pair on a specific Machine’s config.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App the Machine belongs to.
-
machine_id
: string required -
The ID of the Machine to delete some metadata for.
-
key
: string required -
The key of the metadata to delete.
-
- Responses
-
-
204
: -
No content
-
curl -i -X DELETE \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/9080e339b57798/metadata/foo-key"
no body
Notes on networking
Machines are closed to the public internet by default. To make them accessible via the associated application, you need to:
- Allocate an IP address to the Fly App
- Add one or more
services
to the Machine config with ports and handlers, as shown in Create a Machine with services.
For an application with a single Machine, all requests will be routed to that Machine. A Machine in the stopped
state will be started up
automatically when a request arrives.
For an application with multiple Machines with the same configuration, requests will be distributed across them. Warm-start behavior in this situation is not well-defined now, so should not be relied upon for apps with multiple Machines.
Requests to Machines with mixed configurations will be distributed across Machines whose configurations match the request. For example, if 3 out of 6 Machines have service configurations set to listen on port 80, requests to port 80 will be distributed amongst those 3.
Reaching Machines
Machines can be reached within the private network by hostname, in the format <id>.vm.<app-name>.internal
.
For example, to reach a Machine with ID 3d8d413b29d089
on an app called my-app-name
, use hostname 3d8d413b29d089.vm.my-app-name.internal
.
Machine config
object properties
Properties of the config
object for Machine configuration. See Machine properties.
image
: string - Required. The container registry path to the image that defines this Machine (for example, ”registry-1.docker.io/library/ubuntu:latest”).
auto_destroy
: bool (false) - If true, the Machine destroys itself once it’s complete.
checks
: An optional object that defines one or more named checks. The key for each check is the check name. The value for each check supports:
type
: string (nil) -tcp
orhttp
.port
: int (nil) - The TCP port to connect to, likely should be the same asinternal_port
.interval
: int (nil) - The interval, in nanoseconds, between connectivity checkstimeout
: int (nil) - The maximum time, in nanoseconds, a connection can take before being reported as failing its health check.grace_period
: int (nil) - How long to wait, in nanoseconds, before we start running health checks.method
: string (nil) - Forhttp
checks, the HTTP method to use to when making the request.path
: string (nil) - Forhttp
checks, the path to send the request to.protocol
: string (nil) - Forhttp
checks, whether to usehttp
orhttps
tls_server_name
: string (nil) - If the protocol ishttps
, the hostname to use for TLS certificate validationtls_skip_verify
: bool (false) - Forhttp
checks with https protocol, whether or not to verify the TLS certificateheaders
: {string: [string, string]} ({}) - Forhttp
checks, an array of objects with string fieldname
and array of strings fieldvalues
.An example of two checks:
"checks": { "tcp-alive": { "type": "tcp", "port": 8080, "interval": "15s", "timeout": "10s" }, "http-get": { "type": "http", "port": 8080, "protocol": "http" "method": "GET", "path": "/", "interval": "15s", "timeout": "10s" } }
dns
:
nameservers
: Used for Fly Kubernetes.searches
: Used for Fly Kubernetes.options
: Used for Fly Kubernetes.dns_forward_rules
: Used for dedicated hosts.skip_registration
: boolean - If true, do not register the Machine’s 6PN IP with the internal DNS system.
env
: {string:string} ({}) - An object filled with key/value pairs to be set as environment variables.
files
: An optional array of objects defining files to be written within a Machine, one of raw_value
or secret_name
must be provided.
guest_path
: string - The path in the Machine where the file will be written. Must be an absolute path.raw_value
: string - Contains the base64 encoded string of the file contents.secret_name
: string - The name of the secret containing the base64 encoded file contents.An example of two files:
"files": [ { "guest_path": "/path/to/hello.txt", "raw_value": "aGVsbG8gd29ybGQK" }, { "guest_path": "/path/to/secret.txt", "secret_name": "SUPER_SECRET" } ]
guest
: Configure the resources allocated for this Machine. An object with the following options:
cpu_kind
: string (nil) - The type of CPU reservation to make (”shared”, ”performance", and so on).gpu_kind
: string (nil) - The type of GPU reservation to make.host_dedication_id
: The ID of the host dedication (group of dedicated hosts) on which to create this Machine. (beta)cpus
: int (nil) - The number of CPU cores this Machine should occupy when it runs. (default1
)gpus
: int (nil) - The number of GPU cores this Machine should occupy when it runs. (default1
)kernel_args
: Optional array of strings. Arguments passed to the kernel.memory_mb
: int (nil) - Memory in megabytes as multiples of 256 (default256
)
init
: Arguments for init
, which is Fly.io’s footprint inside your Machine, and controls how your own code gets run.
exec
: string, string - The command line for the program to run once the Machine boots up. This overrides any other startup command line, either in our API or in your Docker container definition.entrypoint
: string, string - A command line to override the ENTRYPOINT of your Docker container; another way to define the program that is going to start up when your Machine boots up.cmd
: string, string - A command line to override the CMD of your Docker container; still another way to define the program that is going to start up when your Machine boots up.kernel_args
: Optional array of strings. Arguments passed to the kernel.tty
: bool (false) - Allocate a TTY for the process we start up.swap_size_mb
: int (nil) -Swap space to reserve for the Fly Machine in, you guessed it, megabytes.
metadata
: {string:string} ({}) - An object filled with key/value pairs for the Machine metadata. We use metadata internally for routing, process groups, and clusters.
metrics
: An optional object defining a metrics endpoint that Prometheus on Fly.io will scrape.
port
: int - Required. The port that Prometheus will connect to.path
: string - Required. The path that Prometheus will scrape (e.g./metrics
).
mounts
: An array of objects that reference previously created persistent volumes. Currently, you may only mount one volume per Machine.
volume
: string - Required. The volume ID, visible infly volumes list
. For examplevol_2n0l3vl60qpv635d
.
path
: string - Required. Absolute path on the Machine where the volume should be mounted. For example,/data
.name
: string - The name of the Volume to attach.extend_threshold_percent
: int - The threshold of storage used on a volume, by percentage, that triggers extending the volume’s size by the value ofadd_size_gb
.add_size_gb
: int - The increment, in GB, by which to extend the volume after reaching theauto_extend_size_threshold
. Required withauto_extend_size_increment
. Required withextend_threshold_percent
.size_gb_limit
: int - The total amount, in GB, to extend a volume. Optional withauto_extend_size_increment
. Optional withextend_threshold_percent
.encrypted
: boolean - Volume is encrypted. Default true.
processes
: An optional array of objects defining multiple processes to run within a Machine. The Machine will stop if any process exits without error.
entrypoint
: An array of strings. The process that will run.cmd
: An array of strings. The arguments passed to the entrypoint.env
: An object filled with key/value pairs to be set as environment variables.env_from
: An array of objects that define environment variables from Machine fields. Used for Fly Kubernetes.exec
: An array of strings. The command to run for Machines in this process group on startup.user
: string (nil) - An optional user that the process runs under.ignore_app_secrets
: boolean - If true, only use the secrets provided at the process level. Default false.secrets
: An array of strings. Set the secrets in the environment of the Machine.env_var
is required and is the name of the environment variable that will be set from the secret. It must be a valid environment variable name.name
is optional and when provided is used to reference a secret name where theenv_var
is different from what was set as the secret name.
restart
: Defines whether and how flyd restarts a Machine after its main process exits. Learn more about Machine restart policies. This object has the following options:
policy
: string - Required. One of “no”, “on-failure”, or “always”.max_retries
: int (nil) - The maximum number of retries when the policy is “on-failure”.
schedule
: string (nil) - Optionally one of hourly
, daily
, weekly
, monthly
. Runs Machine at the given interval. Interval starts at time of Machine creation.
services
: An array of objects that define a single network service. Check the Machines networking section for more information.
protocol
: string - Required.tcp
orudp
. Learn more about running raw TCP/UDP services.internal_port
: int - Required. Port the Machine listens on.concurrency
: Control Fly Proxy’s load balancing for this service.type
: string -connections
(TCP) orrequests
(HTTP). Default isconnections
. Determines which kind of event we count for load balancing.soft_limit
: int (nil) - Ideal service concurrency. We will attempt to spread load to keep services at or below this limit. We’ll deprioritize a Machine to give other Machines a chance to absorb traffic. Defaults to 20 when unset.hard_limit
: int (nil) - Maximum allowed concurrency. The limit of events at which we’ll stop routing to a Machine altogether, and, if configured to do so, potentially start up existing Machines to handle the load. Defaults to unlimited when unset.
ports
: MachinePort - An array of objects defining the service’s ports and associated handlers. Options:port
: int (nil) - The internet-exposed port to receive traffic on; if you want HTTP traffic routed to 8080/tcp on your Machine, this would be 80.start_port
,end-port
: int (nil) - Likeport
`, but allocate a range of ports to route internally, for applications that want to occupy whole port ranges.handlers
: Array of protocol handlers for this port. How should the Fly Proxy handle and terminate this connection. Options includehttp
,tcp
,tls
.force_https
: bool (false) - If true, force HTTP to HTTPS redirects.http_options
: Fiddly HTTP options (if you don’t know you need them, you don’t), including:compress
: bool (false) - If true, enable HTTP compression.h2_backend
: bool (false) - If true, inform Fly Proxy that your app supports HTTP/2 (h2c with prior knowledge), which enables HTTP/2 only workloads to work with thehttp
handler.response
: Options for controlling HTTP response headers.headers
: ({“headers”: {string:string}} (nil)) HTTP headers to set on responses.pristine
: bool (false) - If true, do not add any Fly.io headers to HTTP responses. The following response headers won’t be added and won’t be modified if returned by the app:Server
,Via
,Fly-Request-Id
,Fly-Cache-Status
.
tls_options
: Fiddly TLS options (if you don’t know you need to mess with these, you don’t need to), including:alpn
: string, string : ALPN protocols to present TLS clients (for instance, [“h2”, “http/1.1”]).default_self_signed
: bool (false) - If true, serve a self-signed certificate if no certificate exists.versions
: string, string : TLS versions to allow (for instance, [“TLSv1.2”, “TLSv1.3”]).
proxy_proto_options
: Configure the version of the PROXY protocol that your app accepts. Version 1 is the default.version
: A string to indicate that the TCP connection uses PROXY protocol version 2. The default when not set is version 1.
autostart
: bool (false) - If true, Fly Proxy starts Machines when requests for this service arrive.autostop
: string or bool (off
) - One ofoff
(or false),stop
(or true),suspend
. Ifstop
, Fly Proxy stops Machines when this service goes idle. Ifsuspend
, Fly Proxy instead suspends Machines if possible and stops them if not.min_machines_running
: int (nil) - Whenautostart
is true, the minimum number of Machines to keep running at all times in the primary region.
size
: A named size for the VM, e.g. performance-2x
or shared-cpu-2x
. Note: guest
and size
are mutually exclusive.
standbys
: Standbys enable a Machine to be a standby for another. In the event of a hardware failure, the standby Machine will be started. Only for Machines without services
. Array of strings representing the Machine IDs of Machines watch (act as standby for).
statics
: Optionally serve static files.
guest_path
: string - Required. The path inside the Machines or object storage bucket where the files to serve are located.url_prefix
: string - Required. The URL prefix under which to serve the static files.tigris_bucket
: string - The Tigris bucket where the files to serve are located.index_document
: string - The name of the index document, served when a request is made to the root or any of its subfolders. Only works for statics hosted on Tigris
stop_config
: MachineStopConfig (nil) - Configure graceful shutdown of the Machine.
signal
: string (nil) - The name of the signal to send to the entrypoint process on the Machine to initiate shutdown.timeout
: int (nil) - How long in nanoseconds to wait, after signaling the entrypoint process, before hard-shutdown of the Machine.
Related topics
- Working with the Machines API
- Apps resource reference
- Tokens resource reference
- Volumes resource reference