Closed davidfischer-ch closed 4 months ago
Our code using restful provider for reference:
restful
# Update method is implemented on naming API's base path ... # So we are managing the ID to be able to manage the instance. resource "random_uuid" "naming_id" { keepers = { org_id = data.vra_zone.self.org_id } } # Managing the ID to be able to manage the object resource "random_uuid" "naming_project_link_id" { keepers = { org_id = data.vra_zone.self.org_id } } # See Infrastructure as a Service API Swagger for some documentation resource "restful_resource" "naming" { lifecycle { replace_triggered_by = [random_uuid.naming_id] } path = "/iaas/api/naming" create_method = "POST" update_method = "PUT" read_path = "$(path)/$(body.id)" update_path = "$(path)" delete_path = "$(path)/$(body.id)" # FIXME How to update successfully and not recreate when projects are modified ... force_new_attrs = ["id", "projects"] # Not cluttering state and diff with more than this output_attrs = ["id", "name", "description", "templates"] query = { apiVersion = ["2021-07-15"] } # Resource Types: # - COMPUTE # - NETWORK # - COMPUTE_STORAGE # - LOAD_BALANCER # - RESOURCE_GROUP # - GATEWAY # - NAT # - SECURITY_GROUP # - GENERIC body = jsonencode({ id = random_uuid.naming_id.result name = data.vra_region.self.name description = "Convention de nommage (par défaut) pour la région ${data.vra_region.self.name}." projects = [ { active = true defaultOrg = true id = random_uuid.naming_project_link_id.result orgId = data.vra_zone.self.org_id projectId = "*" projectName = "*" } ] templates = [ for pattern in concat([""], local.machine_naming_patterns) : { resourceType = "COMPUTE" resourceTypeName = "Machine" uniqueName = true resourceDefault = pattern == "" startCounter = 1 incrementStep = 1 pattern = join("", [ "$${VM_Common.os_family}", "$${VM_Common.vlan}", "$${VM_Common.srv_role}", "$${VM_Common.cluster}", "$${#####}", # Counter "$${VM_Common.cluster_node}" ]) staticPattern = pattern /* Counters are managed by the platform ... counters = [ { cnResourceType = "COMPUTE" currentCounter = 16 active = true # projectId = "8dc5560d-20c0-4e4e-a9a3-bc19bcb381d7" } ] */ } ] }) }
Our code using
restful
provider for reference: