fix: terraform schema
This commit is contained in:
+38
-7
@@ -5,19 +5,50 @@ resource "ovh_cloud_project_keypair" "deploy_key" {
|
|||||||
region = var.region
|
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
|
service_name = var.ovh_service_name
|
||||||
name = var.instance_name
|
|
||||||
region = var.region
|
region = var.region
|
||||||
flavor_name = var.flavor_name
|
name_filter = var.flavor_name
|
||||||
image_name = var.image_name
|
|
||||||
key_pair = ovh_cloud_project_keypair.deploy_key.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" {
|
resource "local_file" "ansible_inventory" {
|
||||||
content = templatefile("${path.module}/../ansible/inventory.tpl", {
|
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"
|
filename = "${path.module}/../ansible/inventory.ini"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
output "vps_ip" {
|
output "vps_ip" {
|
||||||
description = "The public IPv4 address of the Coolify VPS"
|
description = "The public IPv4 address of the Coolify VPS"
|
||||||
value = ovh_cloud_project_instance.coolify.ipv4_addresses[0]
|
value = [for addr in ovh_cloud_project_instance.coolify.addresses : addr.ip if addr.version == 4][0]
|
||||||
}
|
}
|
||||||
|
|
||||||
output "instance_id" {
|
output "instance_id" {
|
||||||
|
|||||||
Reference in New Issue
Block a user