terraform: created terraform-configurations/2/configuration-2.tf
This commit is contained in:
parent
309dad9213
commit
16e0e5e655
69
terraform-configurations/2/configuration-2.tf
Normal file
69
terraform-configurations/2/configuration-2.tf
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
ovh = {
|
||||||
|
source = "ovh/ovh"
|
||||||
|
version = "2.3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "ovh" {
|
||||||
|
endpoint = "ovh-eu"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable project_id {
|
||||||
|
type = string
|
||||||
|
default = "5a08aa20856c4c549ed18d3fd5c7418a"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable region {
|
||||||
|
type = string
|
||||||
|
default = "SBG5"
|
||||||
|
}
|
||||||
|
|
||||||
|
// The flavor can be selected directly, name_filter in DS does strict equality
|
||||||
|
data "ovh_cloud_project_flavors" "flavors" {
|
||||||
|
service_name = var.project_id
|
||||||
|
name_filter = "r3-16-flex"
|
||||||
|
region = var.region
|
||||||
|
}
|
||||||
|
|
||||||
|
// The image must be selected from it's region based list using name filtering, DS does not support direct selection
|
||||||
|
data ovh_cloud_project_images image{
|
||||||
|
service_name = var.project_id
|
||||||
|
region = "SBG5"
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
selected_image = one([
|
||||||
|
for m in data.ovh_cloud_project_images.image.images : m if m.name == "Ubuntu 22.04"
|
||||||
|
])
|
||||||
|
selected_flavor = one(data.ovh_cloud_project_flavors.flavors.flavors)
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "ovh_cloud_project_instance" "simpl_vm" {
|
||||||
|
service_name = var.project_id
|
||||||
|
region = var.region
|
||||||
|
billing_period = "hourly"
|
||||||
|
boot_from {
|
||||||
|
image_id = local.selected_image.id
|
||||||
|
}
|
||||||
|
flavor {
|
||||||
|
flavor_id = local.selected_flavor.id
|
||||||
|
}
|
||||||
|
name = "offering-enterprise-server-2-terraform"
|
||||||
|
ssh_key_create {
|
||||||
|
name = "default-user-key"
|
||||||
|
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDVAOeyukz7JoSmuY626lBVhXDRniniVV9mOTj+sCQXcJd8GcH03JS20YplDyUrGZEtSrxln3IO19qZ2jjLzOKFAoJxafxoFcw8KdupOQoMsILR05x4myIywCuQtHSdyg+RSyZRBhzcq2elr75uj+Z987hKz56a/sZ4itvRb1W6D7Tq7lhrQqdRZFwi9DrfYIE4S93aDf+I0/IYznY0n5OxQmFpeBeSUIkNGwrBUHsWtzf0/opujUfLzDT5ARJET+oBuOp6WCegp2MBlculD1e/qm2U0AAAcgSDLQeNjBTxjsDj6pLYuUyhMFAjrGRsdwyp6z1odVGbPWcwtkuT60PRnhAvBe+C8P/S/oKeIxtMm7nr0apdVWKu6YW/bar7ulJ17o70/7tlxyVngRluwNKNgtIqKY8NNLhZhSIfGkTw7tKeIX7OAVxMTFZOsSbsUnHOx4eF8Ri8IuNMjdWpJ69bUF2FiLzID3D5JvYhyp1A0ruEGr1HWqWoO2JqIi1mFpM= A200231453@T001273450"
|
||||||
|
}
|
||||||
|
network {
|
||||||
|
public = true
|
||||||
|
}
|
||||||
|
user_data = "I2Nsb3VkLWNvbmZpZw=="
|
||||||
|
}
|
||||||
|
|
||||||
|
// Values defined in outputs are placed in infrastructureDetails
|
||||||
|
output "vmIps" {
|
||||||
|
depends_on = [ovh_cloud_project_instance.simpl_vm]
|
||||||
|
value = tolist(ovh_cloud_project_instance.simpl_vm.addresses[*].ip)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user