Comments (11)
on the ovh_cloud_project_network_private there is a regions_attributes
openstackid
attribute available. So you can create the private_network with ovh_cloud_project_network_private, add a subnet with ovh_cloud_project_network_private_subnet, and it works.
resource "ovh_cloud_project_network_private" "network_prod" {
service_name = var.ovh_project
name = "network-prod"
vlan_id = 0
regions = [var.ovh_region]
}
resource "ovh_cloud_project_network_private_subnet" "network_prod_subnet" {
service_name = var.ovh_project
network_id = ovh_cloud_project_network_private.network_prod.id
region = var.ovh_region
start = "192.168.168.100"
end = "192.168.168.200"
network = "192.168.168.0/24"
dhcp = true
no_gateway = true
}
resource "ovh_cloud_project_kube" "cluster-prod" {
service_name = var.ovh_project
name = "kube-cluster-prod"
region = var.ovh_region
version = "1.20"
private_network_id = ovh_cloud_project_network_private.network_prod.regions_attributes.0.openstackid
}
from terraform-provider-ovh.
Is any workaround available for terraform? I would like to create an ovh_cloud_project_kube resource with a private network, but it requires the openstackId of the network.
from terraform-provider-ovh.
In which version of the provider is the workaround available?
From code in https://github.com/ovh/terraform-provider-ovh/blob/master/ovh/resource_cloud_project_network_private.go it seems it is no longer included in schema. and from https://github.com/ovh/terraform-provider-ovh/blob/master/ovh/types_cloud.go its clear that openstackId is not unmarshalled from the response from api:
type CloudProjectNetworkPrivateResponse struct {
Id string `json:"id"`
Status string `json:"status"`
Vlanid int `json:"vlanId"`
Name string `json:"name"`
Type string `json:"type"`
Regions []*CloudProjectNetworkPrivateRegion `json:"regions"`
}
type CloudProjectNetworkPrivateRegion struct {
Status string `json:"status"`
Region string `json:"region"`
}
Adding a OpenStackId string `json:"openstackId"`
property to CloudProjectNetworkPrivateRegion and map it to a new schema element in func resourceCloudProjectNetworkPrivateRead in https://github.com/ovh/terraform-provider-ovh/blob/master/ovh/resource_cloud_project_network_private.go should do the trick.
Meanwhile, does anyone know of a workaround, is there perhaps a way to use openstack provider to do the private network creation?
from terraform-provider-ovh.
on the ovh_cloud_project_network_private there is a
regions_attributes
openstackid
attribute available. So you can create the private_network with ovh_cloud_project_network_private, add a subnet with ovh_cloud_project_network_private_subnet, and it works.resource "ovh_cloud_project_kube" "cluster-prod" { service_name = var.ovh_project name = "kube-cluster-prod" region = var.ovh_region version = "1.20" private_network_id = ovh_cloud_project_network_private.network_prod.regions_attributes.0.openstackid }
This works fine with a single region, the id '0' matches your region.
I don't see how to do the same when several regions are used. Each region has its own attribute number (which I don't know) and openstackid
from terraform-provider-ovh.
This works fine with a single region, the id '0' matches your region. I don't see how to do the same when several regions are used. Each region has its own attribute number (which I don't know) and openstackid
That'd be trickier, but achievable with latest terraform capabilities (for loop, with an if to find the correct element in the list where region=the value you want) AFAIK. Or, alternatively, loop over the regions_attributes attribute:
! untested:
resource "ovh_cloud_project_kube" "cluster-prod" {
count = length(ovh_cloud_project_network_private.network_prod.regions_attributes)
service_name = var.ovh_project
name = "kube-cluster-prod"
region = var.ovh_region
version = "1.20"
private_network_id = ovh_cloud_project_network_private.network_prod.regions_attributes[count.index].openstackid
}
Would be easier to read with a local region->openstackid map and a for_each
.
from terraform-provider-ovh.
Here a good workaround:
private_network_id = tolist(ovh_cloud_project_network_private.network_prod.regions_attributes)[index(ovh_cloud_project_network_private.network_prod.regions_attributes.*.region, var.ovh_region)].openstackid
I have found the base here:
But when I try (terraform v1.2.9 and OVH provider v0.21.0) I have this error:
Error: Invalid index
│
│ on kubernetes.tf line 15, in resource "ovh_cloud_project_kube" "mykube":
│ 15: private_network_id = ovh_cloud_project_network_private.network_prod.regions_attributes[index(ovh_cloud_project_network_private.network_prod.regions_attributes.*.region, var.ovh_region)].openstackid
│ ├────────────────
│ │ ovh_cloud_project_network_private.network_prod.regions_attributes is set of object with 1 element
│
│ Elements of a set are identified only by their value and don't have any separate index or key to select with, so it's only possible to perform operations across all elements of the set.
To fix it, I add the function tolist
from terraform-provider-ovh.
If you want to select the first element you can also use the one(...)
method like this:
private_network_id = one(ovh_cloud_project_network_private.network.regions_attributes[*].openstackid)
from terraform-provider-ovh.
Ot you can simply use tolist() function and the first index:
private_network_id = tolist(ovh_cloud_project_network_private.network.regions_attributes[*].openstackid)[0]
from terraform-provider-ovh.
Nice, maybe we could update doc with your tips ?
from terraform-provider-ovh.
Yes, I added the tip and also several examples in the documentation.
It will be released in the v0.22.0 :-).
from terraform-provider-ovh.
Seems the issue is fixed by the doc update, closing it.
from terraform-provider-ovh.
Related Issues (20)
- [BUG] list order not consistent in containerregistry_ip_restrictions HOT 3
- [BUG] when creating a public cloud project, got 403 "This order can't be paid with 'bankAccount'" error HOT 6
- [DOCS] Error with doc for datasource ovh_order_cart_product_plan in cloud_project resource on 0.44.0 HOT 1
- [BUG] ovh_cloud_project_kube_oidc crashed HOT 4
- [FEATURE] Project id (Service name) should not be required HOT 3
- [FEATURE] Support `access_token` based provider authentication HOT 4
- [BUG] ovh_domain_zone_record: can't use ttl default value of '0' HOT 2
- When importing `ovh_cloud_project` it forces replacement HOT 3
- [BUG] Impossible to use terraform to configure a compute instance - No suitable endpoint could be found in the service catalog HOT 2
- [BUG] ovh_dedicated_server_install_task fail on invalid partition schema (with no error) HOT 2
- [FEATURE] Create Gateway Interface using the provider HOT 2
- [FEATURE] Use existing floating IP on gateway HOT 3
- [FEATURE] Missing "description" argument in ovh_dedicated_nasha_partition_access HOT 4
- [BUG] `ovh_cloud_project_kube` requires `load_balancers_subnet_id` but doesn't properly update it on the resource HOT 1
- [FEATURE] : allow dedicated server displayName configuration HOT 5
- [FEATURE] [Logs Data Platform] Get the write token of a logs data stream HOT 4
- [FEATURE] [Logs Data Platform] Setting the retention period of a logs data stream HOT 7
- [BUG] Error: Provider produced inconsistent final plan (resource ovh_cloud_project_database with changed node subnet) HOT 1
- [FEATURE] resource_cloud_project_user_s3_policy - add refresh for policy property HOT 3
- [BUG] ovh_cloud_project has constantly the same change after apply with 0.48.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-provider-ovh.