fix: terraform schema

This commit is contained in:
2026-08-12 15:32:55 +02:00
parent b9e736cd80
commit da76e39ce3
2 changed files with 39 additions and 8 deletions
+38 -7
View File
@@ -5,19 +5,50 @@ resource "ovh_cloud_project_keypair" "deploy_key" {
region = var.region
}
resource "ovh_cloud_project_instance" "coolify" {
# 1. Look up the hardware flavor ID dynamically using the flavor name
data "ovh_cloud_project_flavors" "flavor" {
service_name = var.ovh_service_name
name = var.instance_name
region = var.region
flavor_name = var.flavor_name
image_name = var.image_name
key_pair = ovh_cloud_project_keypair.deploy_key.name
name_filter = var.flavor_name
}
# Generate inventory file for Ansible
# 2. Look up the image ID list dynamically for the region
data "ovh_cloud_project_images" "images" {
service_name = var.ovh_service_name
region = var.region
}
resource "ovh_cloud_project_instance" "coolify" {
service_name = var.ovh_service_name
name = var.instance_name
region = var.region
billing_period = "hourly"
# Use flavor block with the retrieved ID
flavor {
flavor_id = tolist(data.ovh_cloud_project_flavors.flavor.flavors)[0].id
}
# Use boot_from block to filter and select the correct image ID
boot_from {
image_id = [for img in data.ovh_cloud_project_images.images.images : img.id if img.name == var.image_name][0]
}
# Use network block to assign a public IP
network {
public = true
}
# Use ssh_key block to attach the deploy key
ssh_key {
name = ovh_cloud_project_keypair.deploy_key.name
}
}
# Generate inventory file for Ansible (using the updated addresses structure)
resource "local_file" "ansible_inventory" {
content = templatefile("${path.module}/../ansible/inventory.tpl", {
vps_ip = ovh_cloud_project_instance.coolify.ipv4_addresses[0]
vps_ip = [for addr in ovh_cloud_project_instance.coolify.addresses : addr.ip if addr.version == 4][0]
})
filename = "${path.module}/../ansible/inventory.ini"
}