I am getting 500/503 errors trying to create machines with the TF provider. It works fine if I use the api directly, so it does not seem to be an API issue like indicated (unless there is some bad setting). All of the other resources in my TF file are created just fine.
With 0.0.20 I get:
│ Error: Failed to create machine
│
│ with fly_machine.firescroll["ewr__rg1"],
│ on main.tf line 56, in resource "fly_machine" "firescroll":
│ 56: resource "fly_machine" "firescroll" {
│
│ Create request failed: 503 Service Unavailable, &{ID: Name: State: Region: InstanceID: PrivateIP: Config:{Env:map[] Init:{Exec:[] Entrypoint:[]
│ Cmd:[]} Image: Metadata:<nil> Restart:{Policy:} Services:[] Mounts:[] Guest:{CPUKind: Cpus:0 MemoryMb:0}} ImageRef:{Registry: Repository: Tag:
│ Digest: Labels:{}} CreatedAt:0001-01-01 00:00:00 +0000 UTC}
0.0.21:
╷
│ Error: Failed to create machine
│
│ with fly_machine.firescroll["ewr__rg1"],
│ on main.tf line 56, in resource "fly_machine" "firescroll":
│ 56: resource "fly_machine" "firescroll" {
│
│ Create request failed: 503 Service Unavailable, {"error":"server returned a non-200 status code: 500"}
│
main.tf
:
# main.tf
terraform {
required_providers {
fly = {
source = "fly-apps/fly"
version = "0.0.21"
}
}
}
provider "fly" {
useinternaltunnel = true
internaltunnelorg = "personal"
internaltunnelregion = "ewr"
}
resource "fly_app" "app" {
name = "firescroll-test" #Replace this with your own app name
org = "personal"
}
resource "fly_ip" "exampleIp" {
app = fly_app.app.name
type = "v4"
depends_on = [fly_app.app]
}
// https://www.daveperrett.com/articles/2021/08/19/nested-for-each-with-terraform/
locals {
regions = ["ewr"]
# , "arn", "atl", "bog", "bos", "cdg", "den", "dfw", "ams", "eze", "gdl", "gig", "gru", "hkg", "iad", "jnb", "lax", "lhr", "mad", "mia", "nrt", "ord", "otp", "qro", "scl", "sea", "sin", "sjc", "syd", "waw", "yul", "yyz"]
replica_groups = [
"rg1"
# , "rg2", "rg3"
]
# Nested loop over both lists, and flatten the result.
consumers = distinct(flatten([
for region in local.regions : [
for replica_group in local.replica_groups : {
region = region
replica_group = replica_group
}
]
]))
}
resource "fly_volume" "vol" {
for_each = { for entry in local.consumers : "${entry.region}__${entry.replica_group}" => entry }
name = each.key
app = fly_app.app.name
size = 50
region = each.value.region
}
resource "fly_machine" "firescroll" {
for_each = { for entry in local.consumers : "${entry.region}__${entry.replica_group}" => entry }
app = fly_app.app.name
region = each.value.region
name = "fs-${each.key}"
image = "ghcr.io/firescroll:v0.1.3"
services = [
{
ports = [
{
port = 80
handlers = ["http"]
}
]
"protocol" : "tcp",
"internal_port" : 8190
},
]
cpus = 4
memorymb = 8192
cputype = "performance"
mounts = [{
path = "/var/firescroll/dbs"
volume = fly_volume.vol[each.key].id
}]
env = {
DEBUG = 1
PRETTY = 1
NAMESPACE = "testns"
REPLICA_GROUP = "testrg"
INSTANCE_ID = "testinstance"
PARTITIONS = 3
KAFKA_SEEDS = "xxx"
}
depends_on = [fly_app.app, fly_volume.vol]
}