hpc: resolve project from the credential for the data sources (E2E fix2)
This commit is contained in:
parent
143cc56ed4
commit
2b9b1220e3
@ -4,20 +4,33 @@
|
|||||||
// credentials and the project (OVH_CLOUD_PROJECT_SERVICE) reach the provider
|
// credentials and the project (OVH_CLOUD_PROJECT_SERVICE) reach the provider
|
||||||
// from the runner environment, never from module inputs.
|
// from the runner environment, never from module inputs.
|
||||||
|
|
||||||
|
// The flavors/images data sources require an explicit service_name (unlike
|
||||||
|
// the resources, they do not fall back to the OVH_CLOUD_PROJECT_SERVICE
|
||||||
|
// runner variable when the attribute is an explicit null), so the project is
|
||||||
|
// resolved from the credential itself when no override is given: the
|
||||||
|
// per-account API keys of the platform are scoped to a single project.
|
||||||
|
data "ovh_cloud_projects" "all" {
|
||||||
|
count = var.project_id == null ? 1 : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
service_name = var.project_id != null ? var.project_id : one(data.ovh_cloud_projects.all[0].projects[*].project_id)
|
||||||
|
}
|
||||||
|
|
||||||
data "ovh_cloud_project_flavors" "head" {
|
data "ovh_cloud_project_flavors" "head" {
|
||||||
service_name = var.project_id
|
service_name = local.service_name
|
||||||
name_filter = var.head_flavor
|
name_filter = var.head_flavor
|
||||||
region = var.region
|
region = var.region
|
||||||
}
|
}
|
||||||
|
|
||||||
data "ovh_cloud_project_flavors" "compute" {
|
data "ovh_cloud_project_flavors" "compute" {
|
||||||
service_name = var.project_id
|
service_name = local.service_name
|
||||||
name_filter = var.compute_flavor
|
name_filter = var.compute_flavor
|
||||||
region = var.region
|
region = var.region
|
||||||
}
|
}
|
||||||
|
|
||||||
data "ovh_cloud_project_images" "all" {
|
data "ovh_cloud_project_images" "all" {
|
||||||
service_name = var.project_id
|
service_name = local.service_name
|
||||||
region = var.region
|
region = var.region
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,14 +50,14 @@ locals {
|
|||||||
// assigned outside the DHCP pool; DHCP stays enabled so the instances
|
// assigned outside the DHCP pool; DHCP stays enabled so the instances
|
||||||
// configure their private interface from the OpenStack metadata.
|
// configure their private interface from the OpenStack metadata.
|
||||||
resource "ovh_cloud_project_network_private" "cluster" {
|
resource "ovh_cloud_project_network_private" "cluster" {
|
||||||
service_name = var.project_id
|
service_name = local.service_name
|
||||||
name = "${var.name_prefix}-hpc-${var.deployment_id}"
|
name = "${var.name_prefix}-hpc-${var.deployment_id}"
|
||||||
regions = [var.region]
|
regions = [var.region]
|
||||||
vlan_id = var.vlan_id
|
vlan_id = var.vlan_id
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "ovh_cloud_project_network_private_subnet" "cluster" {
|
resource "ovh_cloud_project_network_private_subnet" "cluster" {
|
||||||
service_name = var.project_id
|
service_name = local.service_name
|
||||||
network_id = ovh_cloud_project_network_private.cluster.id
|
network_id = ovh_cloud_project_network_private.cluster.id
|
||||||
region = var.region
|
region = var.region
|
||||||
network = var.cluster_cidr
|
network = var.cluster_cidr
|
||||||
@ -69,7 +82,7 @@ locals {
|
|||||||
// through a dual-homed head node is not an option: the cloud's port
|
// through a dual-homed head node is not an option: the cloud's port
|
||||||
// anti-spoofing silently drops the forwarded return traffic.
|
// anti-spoofing silently drops the forwarded return traffic.
|
||||||
resource "ovh_cloud_project_gateway" "egress" {
|
resource "ovh_cloud_project_gateway" "egress" {
|
||||||
service_name = var.project_id
|
service_name = local.service_name
|
||||||
name = "${var.name_prefix}-hpc-gw-${var.deployment_id}"
|
name = "${var.name_prefix}-hpc-gw-${var.deployment_id}"
|
||||||
model = var.gateway_model
|
model = var.gateway_model
|
||||||
region = var.region
|
region = var.region
|
||||||
@ -81,13 +94,13 @@ resource "ovh_cloud_project_gateway" "egress" {
|
|||||||
// on destroy. The instance level ssh_key_create is avoided on purpose: keys it
|
// on destroy. The instance level ssh_key_create is avoided on purpose: keys it
|
||||||
// creates outlive the instance and collide on the next deployment.
|
// creates outlive the instance and collide on the next deployment.
|
||||||
resource "ovh_cloud_project_ssh_key" "admin" {
|
resource "ovh_cloud_project_ssh_key" "admin" {
|
||||||
service_name = var.project_id
|
service_name = local.service_name
|
||||||
name = "${var.name_prefix}-${var.deployment_id}-key"
|
name = "${var.name_prefix}-${var.deployment_id}-key"
|
||||||
public_key = trimspace(tls_private_key.admin.public_key_openssh)
|
public_key = trimspace(tls_private_key.admin.public_key_openssh)
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "ovh_cloud_project_instance" "head" {
|
resource "ovh_cloud_project_instance" "head" {
|
||||||
service_name = var.project_id
|
service_name = local.service_name
|
||||||
region = var.region
|
region = var.region
|
||||||
billing_period = "hourly"
|
billing_period = "hourly"
|
||||||
name = local.head_hostname
|
name = local.head_hostname
|
||||||
@ -133,7 +146,7 @@ resource "ovh_cloud_project_instance" "head" {
|
|||||||
// addresses only carry the fixed private ip, the floating ip is matched
|
// addresses only carry the fixed private ip, the floating ip is matched
|
||||||
// through the port it is associated with.
|
// through the port it is associated with.
|
||||||
data "ovh_cloud_project_floatingips" "all" {
|
data "ovh_cloud_project_floatingips" "all" {
|
||||||
service_name = var.project_id
|
service_name = local.service_name
|
||||||
region_name = var.region
|
region_name = var.region
|
||||||
|
|
||||||
depends_on = [ovh_cloud_project_instance.head]
|
depends_on = [ovh_cloud_project_instance.head]
|
||||||
@ -141,7 +154,7 @@ data "ovh_cloud_project_floatingips" "all" {
|
|||||||
|
|
||||||
resource "ovh_cloud_project_instance" "compute" {
|
resource "ovh_cloud_project_instance" "compute" {
|
||||||
count = var.compute_node_count
|
count = var.compute_node_count
|
||||||
service_name = var.project_id
|
service_name = local.service_name
|
||||||
region = var.region
|
region = var.region
|
||||||
billing_period = "hourly"
|
billing_period = "hourly"
|
||||||
name = local.compute_hostnames[count.index]
|
name = local.compute_hostnames[count.index]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user