# Manage Gyro Cloud Istanbul with the API, gyro CLI and Terraform (tr-ist-1)

https://www.gyrohosting.com/en/knowledgebase/article/gyro-cloud-istanbul-api-cli-terraform

- **What you will learn**: How to create and manage a server in the Istanbul region with the API, the `gyro` command line and Terraform, what is different in this region (no cloud-init, 10 SSH keys) and how prepaid billing affects automation.
- **Time**: 12 minutes
- **Who this is for**: Developers and sysadmins who want to manage infrastructure as code.
- **What you need**: An API key ([First steps with the Gyro API](https://www.gyrohosting.com/en/knowledgebase/article/gyro-api-ilk-adim)), balance and an SSH key. For the CLI, `gyro` 1.10 or later ([installation](https://www.gyrohosting.com/en/knowledgebase/article/gyro-cli-kurulum)); for Terraform, provider 0.9 or later ([Terraform guide](https://www.gyrohosting.com/en/knowledgebase/article/terraform-ile-gyro-bulut)).

## 1. How Istanbul differs

| Topic | Istanbul (`tr-ist-1`) | Europe/US regions |
| --- | --- | --- |
| Billing | Prepaid, hourly (`cycle` is ignored) | Periodic (monthly, quarterly…) |
| `user_data` (cloud-init) | **Rejected with 422** | Supported |
| SSH keys | Up to **10**, installed when the server is ready | 1, installed at creation |
| Images | `ubuntu-24.04`, `ubuntu-22.04`, `debian-12`, `alma-8` | Per region |
| Power actions | `poweron`, `shutdown`/`poweroff`, `reboot` | + `reset`, rescue |
| Backups | None; snapshots available | Per product |
| Metrics | None | Available |
| IPv6 | None | Per region |

The order is paid **from the balance**; if the balance does not cover the first 24 hours the order is rejected ([Topping up](https://www.gyrohosting.com/en/knowledgebase/article/topping-up-balance-and-first-order-rule)).

## 2. With the gyro CLI

```
# Configure (once): key from Client area > Account menu > API Credentials
gyro configure

# Istanbul plans and images
gyro plan list --location tr-ist-1
gyro image list --region tr-ist-1

# Upload your SSH key
gyro ssh-key create ~/.ssh/id_ed25519.pub --name laptop

# Price quote first: nothing is created
gyro server create web-1 --plan standart-2-4 --location tr-ist-1 \
  --image ubuntu-24.04 --ssh-key laptop --dry-run

# Create the server (shows the hourly price and asks for confirmation)
gyro server create web-1 --plan standart-2-4 --location tr-ist-1 \
  --image ubuntu-24.04 --ssh-key laptop --wait

# Connect
gyro server ssh web-1

# Power, snapshot, rDNS, delete
gyro server power reboot web-1
gyro server snapshot create web-1 --wait
gyro server rdns set web-1 --ip 203.0.113.10 --hostname mail.example.com
gyro server delete web-1 --yes
```

> **Info**
> 
> The region is given with `--location`; for Istanbul use `--location tr-ist-1`. In scripts use `--yes` to skip confirmation and `-o json` for machine-readable output. `--user-data` is not accepted in Istanbul.

## 3. With the REST API

The base address is `https://www.gyrohosting.com/api/v1/client` and the identity is `Authorization: Bearer $GYRO_TOKEN`. Orders need an `Idempotency-Key` header and an explicit confirmation (`"confirm": true`).

```
# Images in Istanbul
curl -s "https://www.gyrohosting.com/api/v1/client/cloud/images?region=tr-ist-1" \
  -H "Authorization: Bearer $GYRO_TOKEN"

# Price quote
curl -s -X POST https://www.gyrohosting.com/api/v1/client/cloud/servers \
  -H "Authorization: Bearer $GYRO_TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"plan":"standart-2-4","region":"tr-ist-1","image":"ubuntu-24.04","ssh_keys":[12],"hostname":"web-1.example.com","dry_run":true}'

# Real order (paid from balance)
curl -s -X POST https://www.gyrohosting.com/api/v1/client/cloud/servers \
  -H "Authorization: Bearer $GYRO_TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"plan":"standart-2-4","region":"tr-ist-1","image":"ubuntu-24.04","ssh_keys":[12],"hostname":"web-1.example.com","confirm":true}'
```

The `ssh_keys.state` field in the server detail shows the state of your keys; once it is `installed` you can sign in with your key. Other endpoints: `POST /cloud/servers/{id}/actions` (power, rebuild, password), `POST .../console`, `GET|PUT .../rdns`, `.../snapshots`. On a prepaid server `DELETE /cloud/servers/{id}` is always an immediate cancellation. Details are in the API reference on the `/developers` page.

## 4. With Terraform

```
terraform {
  required_providers {
    gyro = {
      source  = "gyro-hosting/gyro"
      version = ">= 0.9"
    }
  }
}

resource "gyro_ssh_key" "laptop" {
  name       = "laptop"
  public_key = file("~/.ssh/id_ed25519.pub")
}

resource "gyro_server" "web" {
  plan          = "standart-2-4"
  region        = "tr-ist-1"
  image         = "ubuntu-24.04"
  hostname      = "web-1.example.com"
  ssh_key_ids   = [tonumber(gyro_ssh_key.laptop.id)]
  power_state   = "running"
  confirm_order = true # the order is paid from balance
}

output "web_ipv4" {
  value = gyro_server.web.ipv4
}
```

- Do not use `user_data` in Istanbul (it is rejected); you can give up to 10 keys in `ssh_key_ids`.
- `cycle` is ignored on a prepaid product; Terraform does not propose a replacement on every plan.
- `terraform destroy` cancels the service and stops the charge.

## 5. Automation tips

- Use a **separate API key** in CI/CD; tick only the permissions needed (`cloud_read`, `cloud_write`) and add allowed IPs.
- If your script opens a server and does not **delete** it when done, the charge continues. For temporary environments run `gyro server delete --yes` or `terraform destroy` at the end.
- To watch spending use `gyro billing balance get` and `gyro billing usage list` ([The Spending page](https://www.gyrohosting.com/en/knowledgebase/article/spending-page-hour-by-hour-ledger)).

## 6. Frequently asked questions

**Why does user_data return 422?**

cloud-init is not supported in the Istanbul region. For automatic setup use a one-click app, or run a script over SSH once the server is ready.

**I connected before my key was installed and cannot sign in; what should I do?**

Keys are installed after the server is ready (usually a few minutes). Wait for `ssh_keys.state` in `GET /cloud/servers/{id}` to become `installed`.

**The order was rejected with "insufficient balance"; what should I do?**

Your balance must cover the first 24 hours of charge. `gyro billing topup-url get` gives the top-up link.

## Next step

- [Installing the gyro CLI](https://www.gyrohosting.com/en/knowledgebase/article/gyro-cli-kurulum) · [Gyro Cloud with Terraform](https://www.gyrohosting.com/en/knowledgebase/article/terraform-ile-gyro-bulut)
- [API, CLI and Terraform for Gyro Containers](https://www.gyrohosting.com/en/knowledgebase/article/gyro-containers-api-cli-terraform)
