Skip to content

Commit 11226f4

Browse files
Feature: add remaining IonosCloud resources (#1834)
* doc: fix typo in documentation * doc: add template for PRs * fix: fix PR template * fead: add support for Certificate Manager * feat: implement Private CrossConnect * fix: use proper depth for API calls * feat: implement S3 keys * fix: rename a variable and fix a typo in a warning message (#12) * feat: add support for Container Registry (#11) * feat: add support for Data Platform (#13) * feat: add support for IONOSCLOUD shares (#14) * feat: add support for IONOSCLOUD users (#15) * feat: add support for CUBE and VCPU servers (#17) * feat: add support for Container Registry Tokens (#18) * feat: add support for ALB forwarding rules (#19) * feat: Add support for DBaaS Mongo Clusters (#22) * feat: add support for DNS Zones (#20) * feat: add support for DNS Zones * fix: Modify user agent and update documentation with info about mongo clusters * feat: add support for DNS Records (#23) * feat: add support for DBaaS Mongo Users (#24) * feat: add support for DBaaS PgSQL users (#25) * feat: add support for DBaaS PgSQL databases (#26) * feat: add support for Logging Pipelines (#28) * feat: add support for IP failover groups (#27) * refactor: fix linter errors (#29)
1 parent 8ae2440 commit 11226f4

30 files changed

+1151
-45
lines changed

docs/ionoscloud.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,25 @@ export IONOS_TOKEN="token"
3434
* [`application_loadbalancer`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/application_loadbalancer)
3535
* [`networkloadbalancer_forwardingrule`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/networkloadbalancer_forwardingrule)
3636
* [`loadbalancer`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/loadbalancer)
37-
* [`dbaas_pgsql_cluster`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/dbaas_pgsql_cluster)
37+
* [`pg_cluster`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/dbaas_pgsql_cluster)
38+
* [`pg_user`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/dbaas_pgsql_user)
39+
* [`pg_database`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/dbaas_pgsql_database)
40+
* [`mongo_cluster`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/dbaas_mongo_cluster)
41+
* [`mongo_user`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/dbaas_mongo_user)
42+
* [`certificate`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/certificate)
43+
* [`private_crossconnect`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/private_crossconnect)
44+
* [`s3_key`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/s3_key)
45+
* [`container_registry`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/container_registry)
46+
* [`dataplatform_cluster`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/dataplatform_cluster)
47+
* [`dataplatform_node_pool`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/dataplatform_node_pool)
48+
* [`share`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/share)
49+
* [`user`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/user)
50+
* [`container_registry_token`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/container_registry_token)
51+
* [`application_loadbalancer_forwardingrule`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/application_loadbalancer_forwardingrule)
52+
* [`dns_zone`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/dns_zone)
53+
* [`dns_record`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/dns_record)
54+
* [`logging_pipeline`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/logging_pipeline)
55+
* [`ipfailover`](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/latest/docs/resources/ipfailover)
3856

3957
We allow only resources that provide valid terraform plans to be imported.
4058
If you do not see your resource in the tf plan, please enable TF_LOG=debug and check logs

go.mod

+8-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ require (
136136
github.com/hokaccha/go-prettyjson v0.0.0-20210113012101-fb4e108d2519 // indirect
137137
github.com/honeycombio/terraform-provider-honeycombio v0.10.0
138138
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334
139-
github.com/ionos-cloud/sdk-go-dbaas-postgres v1.0.3
139+
github.com/ionos-cloud/sdk-go-dbaas-mongo v1.3.1
140+
github.com/ionos-cloud/sdk-go-dbaas-postgres v1.1.2
140141
github.com/ionos-cloud/sdk-go/v6 v6.1.3
141142
github.com/jefferai/jsonx v1.0.1 // indirect
142143
github.com/jmespath/go-jmespath v0.4.0
@@ -392,6 +393,12 @@ require (
392393
)
393394

394395
require (
396+
github.com/gofrs/uuid/v3 v3.1.2
397+
github.com/ionos-cloud/sdk-go-cert-manager v1.0.0
398+
github.com/ionos-cloud/sdk-go-container-registry v1.0.0
399+
github.com/ionos-cloud/sdk-go-dataplatform v1.0.1
400+
github.com/ionos-cloud/sdk-go-dns v1.1.1
401+
github.com/ionos-cloud/sdk-go-logging v1.0.1
395402
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.392
396403
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.392
397404
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdb v1.0.392

go.sum

+16-2
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,8 @@ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x
782782
github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
783783
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
784784
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
785+
github.com/gofrs/uuid/v3 v3.1.2 h1:V3IBv1oU82x6YIr5txe3azVHgmOKYdyKQTowm9moBlY=
786+
github.com/gofrs/uuid/v3 v3.1.2/go.mod h1:xPwMqoocQ1L5G6pXX5BcE7N5jlzn2o19oqAKxwZW/kI=
785787
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
786788
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
787789
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
@@ -1063,8 +1065,20 @@ github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
10631065
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
10641066
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
10651067
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
1066-
github.com/ionos-cloud/sdk-go-dbaas-postgres v1.0.3 h1:ahzztBNJ1IcQL+hdzhek6234P4ednkqdOgTsfB0nEfE=
1067-
github.com/ionos-cloud/sdk-go-dbaas-postgres v1.0.3/go.mod h1:87cFAQViqjorhuafmYIDCmCTr5GiaqDB7qr09K1gdOU=
1068+
github.com/ionos-cloud/sdk-go-cert-manager v1.0.0 h1:pPIhdjTB3rjP9x3Cf6B4j8NTZ1u2v/w7/0h7GtFs/Ig=
1069+
github.com/ionos-cloud/sdk-go-cert-manager v1.0.0/go.mod h1:nFzMT0UNtNiLIuDGYj8pulHFQiVVql43oEX/eQIyr5Q=
1070+
github.com/ionos-cloud/sdk-go-container-registry v1.0.0 h1:03FKtFfHdOPZdXxRAFWgivbhmkyY4xk+R79EffoFt/4=
1071+
github.com/ionos-cloud/sdk-go-container-registry v1.0.0/go.mod h1:AtjqGZWAvd5J1rRR0wHhZ8nMrR/yJm45z8KB3p8rrvs=
1072+
github.com/ionos-cloud/sdk-go-dataplatform v1.0.1 h1:3BeDDlHl9mQAYmgdg8EsgsXbPMDfL4pJhXzmTPHNpA0=
1073+
github.com/ionos-cloud/sdk-go-dataplatform v1.0.1/go.mod h1:YitNqq01IAbzMr1GpXIDW1+pvhiY9eUs7/+rB9UitXE=
1074+
github.com/ionos-cloud/sdk-go-dbaas-mongo v1.3.1 h1:+tDoZ8IEPxYwJd6fDIpWksNJs9Zzw7Pu5A39jTew058=
1075+
github.com/ionos-cloud/sdk-go-dbaas-mongo v1.3.1/go.mod h1:rxOAeyAU6BTfghJibSRDdRNrKm2cIXMpSMe7JIWewJ8=
1076+
github.com/ionos-cloud/sdk-go-dbaas-postgres v1.1.2 h1:AaKbci+kVS6/k43VwJwmXxCJ7pzj9jwuOPqO8Wd5560=
1077+
github.com/ionos-cloud/sdk-go-dbaas-postgres v1.1.2/go.mod h1:nmJEwuRX65A5/PxwvdFW0XrV+N6WFYnMV1TiIafAwz4=
1078+
github.com/ionos-cloud/sdk-go-dns v1.1.1 h1:Qdf5mXYt9ZeRl4zZQxGrvamFkKm1X9WeARyB9/WYhKg=
1079+
github.com/ionos-cloud/sdk-go-dns v1.1.1/go.mod h1:l9gYdwtUshlBOiIi4nHn3RCX81XlV3VoNvLJrO2VfHg=
1080+
github.com/ionos-cloud/sdk-go-logging v1.0.1 h1:MB9jPoBUL3mZ+ois7kXYy67x0FopAw2aihMGdr2wu1k=
1081+
github.com/ionos-cloud/sdk-go-logging v1.0.1/go.mod h1:P2JQJpUgH3ZyfyJmv6jMwcB1NJIVVZSL+/bllhWpwc8=
10681082
github.com/ionos-cloud/sdk-go/v6 v6.1.3 h1:vb6yqdpiqaytvreM0bsn2pXw+1YDvEk2RKSmBAQvgDQ=
10691083
github.com/ionos-cloud/sdk-go/v6 v6.1.3/go.mod h1:Ox3W0iiEz0GHnfY9e5LmAxwklsxguuNFEUSu0gVRTME=
10701084
github.com/jefferai/jsonx v1.0.1 h1:GvWkLWihoLqDG0BSP45TUQJH9qsINX50PVrFULgpc/I=
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package ionoscloud
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/GoogleCloudPlatform/terraformer/providers/ionoscloud/helpers"
8+
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
9+
)
10+
11+
type ALBForwardingRuleGenerator struct {
12+
Service
13+
}
14+
15+
func (g *ALBForwardingRuleGenerator) InitResources() error {
16+
client := g.generateClient()
17+
cloudAPIClient := client.CloudAPIClient
18+
resourceType := "ionoscloud_application_loadbalancer_forwardingrule"
19+
datacenters, err := helpers.GetAllDatacenters(*cloudAPIClient)
20+
if err != nil {
21+
return err
22+
}
23+
for _, datacenter := range datacenters {
24+
applicationLoadBalancerResponse, _, err := cloudAPIClient.ApplicationLoadBalancersApi.DatacentersApplicationloadbalancersGet(context.TODO(), *datacenter.Id).Depth(1).Execute()
25+
if err != nil {
26+
return err
27+
}
28+
if applicationLoadBalancerResponse.Items == nil {
29+
log.Printf(
30+
"[WARNING] expected a response containing application load balancers but received 'nil' instead, skipping search for datacenter with ID: %v",
31+
*datacenter.Id)
32+
continue
33+
}
34+
applicationLoadBalancers := *applicationLoadBalancerResponse.Items
35+
for _, applicationLoadBalancer := range applicationLoadBalancers {
36+
if applicationLoadBalancer.Properties == nil || applicationLoadBalancer.Properties.Name == nil {
37+
log.Printf(
38+
"[WARNING] 'nil' values in the response for application load balancer with ID %v, datacenter ID: %v, skipping this resource",
39+
*applicationLoadBalancer.Id,
40+
*datacenter.Id,
41+
)
42+
continue
43+
}
44+
albForwardingRulesResponse, _, err := cloudAPIClient.ApplicationLoadBalancersApi.DatacentersApplicationloadbalancersForwardingrulesGet(context.TODO(), *datacenter.Id, *applicationLoadBalancer.Id).Depth(1).Execute()
45+
if err != nil {
46+
return err
47+
}
48+
if albForwardingRulesResponse.Items == nil {
49+
log.Printf("[WARNING] expected a response containing ALB forwarding rules but received 'nil' instead, skipping search for ALB with ID: %v, datacenter ID: %v", *applicationLoadBalancer.Id, *datacenter.Id)
50+
continue
51+
}
52+
albForwardingRules := *albForwardingRulesResponse.Items
53+
for _, albForwardingRule := range albForwardingRules {
54+
if albForwardingRule.Properties == nil || albForwardingRule.Properties.Name == nil {
55+
log.Printf("[WARNING] 'nil' values in the response for ALB forwarding rule with ID: %v, ALB ID: %v, datacenter ID: %v, skipping this resource", *albForwardingRule.Id, *applicationLoadBalancer.Id, *datacenter.Id)
56+
continue
57+
}
58+
g.Resources = append(g.Resources, terraformutils.NewResource(
59+
*albForwardingRule.Id,
60+
*albForwardingRule.Properties.Name+"-"+*albForwardingRule.Id,
61+
resourceType,
62+
helpers.Ionos,
63+
map[string]string{"application_loadbalancer_id": *applicationLoadBalancer.Id, helpers.DcID: *datacenter.Id},
64+
[]string{},
65+
map[string]interface{}{}))
66+
}
67+
}
68+
}
69+
return nil
70+
}

providers/ionoscloud/certificate.go

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package ionoscloud
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/GoogleCloudPlatform/terraformer/providers/ionoscloud/helpers"
8+
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
9+
)
10+
11+
type CertificateGenerator struct {
12+
Service
13+
}
14+
15+
func (g *CertificateGenerator) InitResources() error {
16+
client := g.generateClient()
17+
certManagerAPIClient := client.CertificateManagerAPIClient
18+
resourceType := "ionoscloud_certificate"
19+
20+
response, _, err := certManagerAPIClient.CertificatesApi.CertificatesGet(context.TODO()).Execute()
21+
if err != nil {
22+
return err
23+
}
24+
if response.Items == nil {
25+
log.Printf("[WARNING] expected a response containing certificates but received 'nil' instead.")
26+
return nil
27+
}
28+
certificates := *response.Items
29+
for _, certificate := range certificates {
30+
if certificate.Properties == nil || certificate.Properties.Name == nil {
31+
log.Printf("[WARNING] 'nil' values in the response for the certificate with ID %v, skipping this resource.", *certificate.Id)
32+
continue
33+
}
34+
g.Resources = append(g.Resources, terraformutils.NewResource(
35+
*certificate.Id,
36+
*certificate.Properties.Name+"-"+*certificate.Id,
37+
resourceType,
38+
helpers.Ionos,
39+
map[string]string{},
40+
[]string{},
41+
map[string]interface{}{}))
42+
}
43+
return nil
44+
}
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package ionoscloud
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/GoogleCloudPlatform/terraformer/providers/ionoscloud/helpers"
8+
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
9+
)
10+
11+
type ContainerRegistryGenerator struct {
12+
Service
13+
}
14+
15+
func (g *ContainerRegistryGenerator) InitResources() error {
16+
client := g.generateClient()
17+
containerRegistryAPIClient := client.ContainerRegistryAPIClient
18+
resourceType := "ionoscloud_container_registry"
19+
20+
response, _, err := containerRegistryAPIClient.RegistriesApi.RegistriesGet(context.TODO()).Execute()
21+
if err != nil {
22+
return err
23+
}
24+
if response.Items == nil {
25+
log.Printf("[WARNING] expected a response containing registries but received 'nil' instead.")
26+
return nil
27+
}
28+
registries := *response.Items
29+
for _, registry := range registries {
30+
if registry.Properties == nil || registry.Properties.Name == nil {
31+
log.Printf("[WARNING] 'nil' values in the response for the registry with ID %v, skipping this resource.", *registry.Id)
32+
continue
33+
}
34+
g.Resources = append(g.Resources, terraformutils.NewResource(
35+
*registry.Id,
36+
*registry.Properties.Name+"-"+*registry.Id,
37+
resourceType,
38+
helpers.Ionos,
39+
map[string]string{},
40+
[]string{},
41+
map[string]interface{}{}))
42+
}
43+
return nil
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package ionoscloud
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/GoogleCloudPlatform/terraformer/providers/ionoscloud/helpers"
8+
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
9+
)
10+
11+
type ContainerRegistryTokenGenerator struct {
12+
Service
13+
}
14+
15+
func (g *ContainerRegistryTokenGenerator) InitResources() error {
16+
client := g.generateClient()
17+
crClient := client.ContainerRegistryAPIClient
18+
resourceType := "ionoscloud_container_registry_token"
19+
20+
registriesResponse, _, err := crClient.RegistriesApi.RegistriesGet(context.TODO()).Execute()
21+
if err != nil {
22+
return err
23+
}
24+
if registriesResponse.Items == nil {
25+
log.Printf("[WARNING] expected a response containing registries but received 'nil' instead")
26+
return nil
27+
}
28+
registries := *registriesResponse.Items
29+
for _, registry := range registries {
30+
tokensResponse, _, err := crClient.TokensApi.RegistriesTokensGet(context.TODO(), *registry.Id).Execute()
31+
if err != nil {
32+
return err
33+
}
34+
if tokensResponse.Items == nil {
35+
log.Printf("[WARNING] expected a response containing container registry tokens, but received 'nil' instead")
36+
return nil
37+
}
38+
crTokens := *tokensResponse.Items
39+
for _, crToken := range crTokens {
40+
if crToken.Properties == nil || crToken.Properties.Name == nil {
41+
log.Printf("[WARNING] 'nil' values in the response for the container registry token with ID: %v, skipping this resource", *crToken.Id)
42+
continue
43+
}
44+
g.Resources = append(g.Resources, terraformutils.NewResource(
45+
*crToken.Id,
46+
*crToken.Properties.Name+"-"+*crToken.Id,
47+
resourceType,
48+
helpers.Ionos,
49+
map[string]string{"registry_id": *registry.Id},
50+
[]string{},
51+
map[string]interface{}{}))
52+
}
53+
}
54+
return nil
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package ionoscloud
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/GoogleCloudPlatform/terraformer/providers/ionoscloud/helpers"
8+
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
9+
)
10+
11+
type DataPlatformClusterGenerator struct {
12+
Service
13+
}
14+
15+
func (g *DataPlatformClusterGenerator) InitResources() error {
16+
client := g.generateClient()
17+
dataPlatformClient := client.DataPlatformAPIClient
18+
resourceType := "ionoscloud_dataplatform_cluster"
19+
20+
response, _, err := dataPlatformClient.DataPlatformClusterApi.ClustersGet(context.TODO()).Execute()
21+
if err != nil {
22+
return err
23+
}
24+
if response.Items == nil {
25+
log.Printf("[WARNING] expected a response containing data platform clusters, but received 'nil' instead.")
26+
return nil
27+
}
28+
clusters := *response.Items
29+
for _, cluster := range clusters {
30+
if cluster.Properties == nil || cluster.Properties.Name == nil {
31+
log.Printf("[WARNING] 'nil' values in the response for data platform cluster with ID %v, skipping this resource.", *cluster.Id)
32+
continue
33+
}
34+
g.Resources = append(g.Resources, terraformutils.NewResource(
35+
*cluster.Id,
36+
*cluster.Properties.Name+"-"+*cluster.Id,
37+
resourceType,
38+
helpers.Ionos,
39+
map[string]string{},
40+
[]string{},
41+
map[string]interface{}{}))
42+
}
43+
return nil
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package ionoscloud
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/GoogleCloudPlatform/terraformer/providers/ionoscloud/helpers"
8+
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
9+
)
10+
11+
type DataPlatformNodePoolGenerator struct {
12+
Service
13+
}
14+
15+
func (g *DataPlatformNodePoolGenerator) InitResources() error {
16+
client := g.generateClient()
17+
dataPlatformClient := client.DataPlatformAPIClient
18+
resourceType := "ionoscloud_dataplatform_node_pool"
19+
20+
dpClusters, _, err := dataPlatformClient.DataPlatformClusterApi.ClustersGet(context.TODO()).Execute()
21+
if err != nil {
22+
return err
23+
}
24+
if dpClusters.Items == nil {
25+
log.Printf("[WARNING] expected a response containing data platform clusters but received 'nil' instead.")
26+
return nil
27+
}
28+
for _, dpCluster := range *dpClusters.Items {
29+
dpNodePools, _, err := dataPlatformClient.DataPlatformNodePoolApi.ClustersNodepoolsGet(context.TODO(), *dpCluster.Id).Execute()
30+
if err != nil {
31+
return err
32+
}
33+
if dpNodePools.Items == nil {
34+
log.Printf("[WARNING] expected a response containing data platform node pools but received 'nil' instead, skipping search for data platform cluster with ID: %v", *dpCluster.Id)
35+
continue
36+
}
37+
for _, dpNodePool := range *dpNodePools.Items {
38+
if dpNodePool.Properties == nil || dpNodePool.Properties.Name == nil {
39+
log.Printf("[WARNING] 'nil' values in the response for data platform node pool with ID %v, cluster ID: %v, skipping this resource",
40+
*dpNodePool.Id,
41+
*dpCluster.Id)
42+
continue
43+
}
44+
g.Resources = append(g.Resources, terraformutils.NewResource(
45+
*dpNodePool.Id,
46+
*dpNodePool.Properties.Name+"-"+*dpNodePool.Id,
47+
resourceType,
48+
helpers.Ionos,
49+
map[string]string{helpers.ClusterID: *dpCluster.Id},
50+
[]string{},
51+
map[string]interface{}{}))
52+
}
53+
}
54+
return nil
55+
}

0 commit comments

Comments
 (0)