Skip to content

Commit d4014e5

Browse files
Add SDSaaS to terraform provider (IBM-Cloud#5772)
* Add SDSaaS to terraform provider * Cleanup * Rebase * Update based on changes and rebase * Updates * Make resources use the sds_endpoint
1 parent 9e8d7e6 commit d4014e5

17 files changed

+1632
-7
lines changed

examples/ibm-sdsaas/README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Examples for sdsaas
2+
3+
These examples illustrate how to use the resources and data sources associated with sdsaas.
4+
5+
The following resources are supported:
6+
* ibm_sds_volume
7+
* ibm_sds_host
8+
9+
## Usage
10+
11+
To run this example, execute the following commands:
12+
13+
```bash
14+
$ terraform init
15+
$ terraform plan
16+
$ terraform apply
17+
```
18+
19+
Run `terraform destroy` when you don't need these resources.
20+
21+
## sdsaas resources
22+
23+
### Resource: ibm_sds_volume
24+
25+
```hcl
26+
resource "ibm_sds_volume" "sds_volume_instance" {
27+
sds_endpoint = var.sds_endpoint
28+
hostnqnstring = var.sds_volume_hostnqnstring
29+
capacity = var.sds_volume_capacity
30+
name = var.sds_volume_name
31+
}
32+
```
33+
34+
#### Inputs
35+
36+
| Name | Description | Type | Required |
37+
|------|-------------|------|---------|
38+
| ibmcloud\_api\_key | IBM Cloud API key | `string` | true |
39+
| sds_endpoint | IBM Cloud Endpoint | `string` | false |
40+
| hostnqnstring | The host nqn. | `string` | false |
41+
| capacity | The capacity of the volume (in gigabytes). | `number` | true |
42+
| name | The name of the volume. | `string` | false |
43+
44+
#### Outputs
45+
46+
| Name | Description |
47+
|------|-------------|
48+
| bandwidth | The maximum bandwidth (in megabits per second) for the volume. |
49+
| created_at | The date and time that the volume was created. |
50+
| hosts | List of host details that volume is mapped to. |
51+
| iops | Iops The maximum I/O operations per second (IOPS) for this volume. |
52+
| resource_type | The resource type of the volume. |
53+
| status | The current status of the volume. |
54+
| status_reasons | Reasons for the current status of the volume. |
55+
56+
### Resource: ibm_sds_host
57+
58+
```hcl
59+
resource "ibm_sds_host" "sds_host_instance" {
60+
sds_endpoint = var.sds_endpoint
61+
name = var.sds_host_name
62+
nqn = var.sds_host_nqn
63+
volumes = var.sds_host_volumes
64+
}
65+
```
66+
67+
#### Inputs
68+
69+
| Name | Description | Type | Required |
70+
|------|-------------|------|---------|
71+
| ibmcloud\_api\_key | IBM Cloud API key | `string` | true |
72+
| sds_endpoint | IBM Cloud Endpoint | `string` | false |
73+
| name | The name for this host. The name must not be used by another host. If unspecified, the name will be a hyphenated list of randomly-selected words. | `string` | false |
74+
| nqn | The NQN of the host configured in customer's environment. | `string` | true |
75+
| volumes | The host-to-volume map. | `list()` | false |
76+
77+
#### Outputs
78+
79+
| Name | Description |
80+
|------|-------------|
81+
| created_at | The date and time that the host was created. |
82+
83+
84+
## Assumptions
85+
86+
The `IBMCLOUD_SDS_ENDPOINT` can optionally be set instead of setting `sds_endpoint` in each of the resources. This is the endpoint provided to customers to perform operations against their service.
87+
88+
## Requirements
89+
90+
| Name | Version |
91+
|------|---------|
92+
| terraform | ~> 0.12 |
93+
94+
## Providers
95+
96+
| Name | Version |
97+
|------|---------|
98+
| ibm | 1.13.1 |

examples/ibm-sdsaas/main.tf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
provider "ibm" {
2+
ibmcloud_api_key = var.ibmcloud_api_key
3+
}
4+
5+
// Provision sds_volume resource instance
6+
resource "ibm_sds_volume" "sds_volume_instance_1" {
7+
sds_endpoint = var.sds_endpoint
8+
9+
hostnqnstring = var.sds_volume_hostnqnstring
10+
capacity = var.sds_volume_capacity
11+
name = var.sds_volume_name_1
12+
}
13+
14+
// Provision sds_volume resource instance
15+
resource "ibm_sds_volume" "sds_volume_instance_2" {
16+
sds_endpoint = var.sds_endpoint
17+
18+
hostnqnstring = var.sds_volume_hostnqnstring
19+
capacity = var.sds_volume_capacity
20+
name = var.sds_volume_name_2
21+
}
22+
23+
// Provision sds_host resource instance
24+
resource "ibm_sds_host" "sds_host_instance" {
25+
sds_endpoint = var.sds_endpoint
26+
27+
name = var.sds_host_name
28+
nqn = var.sds_host_nqn
29+
volumes {
30+
volume_id = ibm_sds_volume.sds_volume_instance_1.id
31+
volume_name = ibm_sds_volume.sds_volume_instance_1.name
32+
}
33+
volumes {
34+
volume_id = ibm_sds_volume.sds_volume_instance_2.id
35+
volume_name = ibm_sds_volume.sds_volume_instance_2.name
36+
}
37+
}

examples/ibm-sdsaas/outputs.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This output allows sds_volume data to be referenced by other resources and the terraform CLI
2+
// Modify this output if only certain data should be exposed
3+
output "ibm_sds_volume" {
4+
value = [ibm_sds_volume.sds_volume_instance_1, ibm_sds_volume.sds_volume_instance_2]
5+
description = "sds_volume resource instance"
6+
}
7+
// This output allows sds_host data to be referenced by other resources and the terraform CLI
8+
// Modify this output if only certain data should be exposed
9+
output "ibm_sds_host" {
10+
value = ibm_sds_host.sds_host_instance
11+
description = "sds_host resource instance"
12+
}

examples/ibm-sdsaas/variables.tf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
variable "ibmcloud_api_key" {
2+
description = "IBM Cloud API key"
3+
type = string
4+
}
5+
6+
variable "sds_endpoint" {
7+
description = "IBM SDS Endpoint"
8+
type = string
9+
default = "<endpoint>"
10+
}
11+
12+
variable "sds_volume_hostnqnstring" {
13+
description = "The host nqn."
14+
type = string
15+
default = "nqn.2014-06.org:9345"
16+
}
17+
variable "sds_volume_capacity" {
18+
description = "The capacity of the volume (in gigabytes)."
19+
type = number
20+
default = 10
21+
}
22+
variable "sds_volume_name_1" {
23+
description = "The name of the volume."
24+
type = string
25+
default = "demo-volume-1"
26+
}
27+
28+
variable "sds_volume_name_2" {
29+
description = "The name of the volume."
30+
type = string
31+
default = "demo-volume-2"
32+
}
33+
34+
variable "sds_host_name" {
35+
description = "The name for this host. The name must not be used by another host. If unspecified, the name will be a hyphenated list of randomly-selected words."
36+
type = string
37+
default = "demo-host"
38+
}
39+
variable "sds_host_nqn" {
40+
description = "The NQN of the host configured in customer's environment."
41+
type = string
42+
default = "nqn.2014-06.org:9345"
43+
}

examples/ibm-sdsaas/versions.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
required_providers {
4+
ibm = {
5+
source = "IBM-Cloud/ibm"
6+
version = "1.71.0-beta1"
7+
}
8+
}
9+
}

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ require (
3939
github.com/IBM/sarama v1.41.2
4040
github.com/IBM/scc-go-sdk/v5 v5.4.1
4141
github.com/IBM/schematics-go-sdk v0.3.0
42+
github.com/IBM/sds-go-sdk v0.0.4
4243
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.7
4344
github.com/IBM/vmware-go-sdk v0.1.2
4445
github.com/IBM/vpc-beta-go-sdk v0.8.0
@@ -101,7 +102,7 @@ require (
101102
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
102103
github.com/fatih/color v1.16.0 // indirect
103104
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
104-
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
105+
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
105106
github.com/go-jose/go-jose/v4 v4.0.1 // indirect
106107
github.com/go-logr/logr v1.4.2 // indirect
107108
github.com/go-logr/stdr v1.2.2 // indirect
@@ -200,7 +201,7 @@ require (
200201
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
201202
github.com/x448/float16 v0.8.4 // indirect
202203
github.com/zclconf/go-cty v1.15.0 // indirect
203-
go.mongodb.org/mongo-driver v1.16.1 // indirect
204+
go.mongodb.org/mongo-driver v1.17.1 // indirect
204205
go.opentelemetry.io/otel v1.28.0 // indirect
205206
go.opentelemetry.io/otel/metric v1.28.0 // indirect
206207
go.opentelemetry.io/otel/trace v1.28.0 // indirect

go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ github.com/IBM/scc-go-sdk/v5 v5.4.1 h1:RXIuxOo9/hxkWyHCI69ae+KIJgSbXcAkJwTEl+fO3
168168
github.com/IBM/scc-go-sdk/v5 v5.4.1/go.mod h1:2xQTDgNXG5QMEfQxBDKB067z+5ha6OgcaKCTcdGDAo8=
169169
github.com/IBM/schematics-go-sdk v0.3.0 h1:Vwxw85SONflakiBsNHAfViKLyp9zJiH5/hh6SewOP5Q=
170170
github.com/IBM/schematics-go-sdk v0.3.0/go.mod h1:Tw2OSAPdpC69AxcwoyqcYYaGTTW6YpERF9uNEU+BFRQ=
171+
github.com/IBM/sds-go-sdk v0.0.4 h1:zkkqDzc+TgFYU/BK4Oknv8cMBXJ08WKUu7yKCyzslvE=
172+
github.com/IBM/sds-go-sdk v0.0.4/go.mod h1:HcqZfsgKMqfFxbU1RcRfF934ls+vQY97oXPGPSoIWPg=
171173
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.7 h1:5lKt1rHuKaAaiZtbPfsF8dgiko/gGbVgreiut3zU128=
172174
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.7/go.mod h1:RglK3v6CPe3T1myRtQCD6z+nBygXvNJwufAon0qcZok=
173175
github.com/IBM/vmware-go-sdk v0.1.2 h1:5lKWFyInWz9e2hwGsoFTEoLa1jYkD30SReN0fQ10w9M=
@@ -368,8 +370,8 @@ github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8
368370
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
369371
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
370372
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
371-
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
372-
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
373+
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
374+
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
373375
github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg=
374376
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
375377
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
@@ -1268,8 +1270,8 @@ go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4x
12681270
go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8=
12691271
go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
12701272
go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
1271-
go.mongodb.org/mongo-driver v1.16.1 h1:rIVLL3q0IHM39dvE+z2ulZLp9ENZKThVfuvN/IiN4l8=
1272-
go.mongodb.org/mongo-driver v1.16.1/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw=
1273+
go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM=
1274+
go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4=
12731275
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
12741276
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
12751277
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=

ibm/conns/config.go

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11-
"github.com/IBM/cloud-db2-go-sdk/db2saasv1"
1211
"io"
1312
"io/ioutil"
1413
"log"
@@ -18,6 +17,8 @@ import (
1817
"strings"
1918
"time"
2019

20+
"github.com/IBM/cloud-db2-go-sdk/db2saasv1"
21+
2122
// Added code for the Power Colo Offering
2223

2324
"github.com/IBM-Cloud/container-services-go-sdk/kubernetesserviceapiv1"
@@ -86,6 +87,7 @@ import (
8687
project "github.com/IBM/project-go-sdk/projectv1"
8788
"github.com/IBM/push-notifications-go-sdk/pushservicev1"
8889
schematicsv1 "github.com/IBM/schematics-go-sdk/schematicsv1"
90+
"github.com/IBM/sds-go-sdk/sdsaasv1"
8991
"github.com/IBM/vmware-go-sdk/vmwarev1"
9092
vpcbeta "github.com/IBM/vpc-beta-go-sdk/vpcbetav1"
9193
"github.com/IBM/vpc-go-sdk/common"
@@ -319,6 +321,7 @@ type ClientSession interface {
319321
MqcloudV1() (*mqcloudv1.MqcloudV1, error)
320322
VmwareV1() (*vmwarev1.VmwareV1, error)
321323
LogsV0() (*logsv0.LogsV0, error)
324+
SdsaasV1() (*sdsaasv1.SdsaasV1, error)
322325
}
323326

324327
type clientSession struct {
@@ -680,6 +683,10 @@ type clientSession struct {
680683
// db2 saas
681684
db2saasClient *db2saasv1.Db2saasV1
682685
db2saasClientErr error
686+
687+
// Software Defined Storage
688+
sdsaasClient *sdsaasv1.SdsaasV1
689+
sdsaasClientErr error
683690
}
684691

685692
// Usage Reports
@@ -1294,6 +1301,11 @@ func (session clientSession) MqcloudV1() (*mqcloudv1.MqcloudV1, error) {
12941301
return session.mqcloudClient.Clone(), nil
12951302
}
12961303

1304+
// sdsaas
1305+
func (session clientSession) SdsaasV1() (*sdsaasv1.SdsaasV1, error) {
1306+
return session.sdsaasClient, session.sdsaasClientErr
1307+
}
1308+
12971309
// VMware as a Service API
12981310
func (session clientSession) VmwareV1() (*vmwarev1.VmwareV1, error) {
12991311
return session.vmwareClient, session.vmwareClientErr
@@ -3595,6 +3607,27 @@ func (c *Config) ClientSession() (interface{}, error) {
35953607
session.codeEngineClientErr = fmt.Errorf("Error occurred while configuring Code Engine service: %q", err)
35963608
}
35973609

3610+
// Construct an instance of the 'sdsaas' service.
3611+
if session.sdsaasClientErr == nil {
3612+
// Construct the service options.
3613+
sdsaasClientOptions := &sdsaasv1.SdsaasV1Options{
3614+
Authenticator: authenticator,
3615+
}
3616+
3617+
// Construct the service client.
3618+
session.sdsaasClient, err = sdsaasv1.NewSdsaasV1(sdsaasClientOptions)
3619+
if err == nil {
3620+
// Enable retries for API calls
3621+
session.sdsaasClient.Service.EnableRetries(c.RetryCount, c.RetryDelay)
3622+
// Add custom header for analytics
3623+
session.sdsaasClient.SetDefaultHeaders(gohttp.Header{
3624+
"X-Original-User-Agent": {fmt.Sprintf("terraform-provider-ibm/%s", version.Version)},
3625+
})
3626+
} else {
3627+
session.sdsaasClientErr = fmt.Errorf("Error occurred while constructing 'sdsaas' service client: %q", err)
3628+
}
3629+
}
3630+
35983631
if os.Getenv("TF_LOG") != "" {
35993632
logDestination := log.Writer()
36003633
goLogger := log.New(logDestination, "", log.LstdFlags)

ibm/provider/provider.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import (
6464
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/satellite"
6565
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/scc"
6666
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/schematics"
67+
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/sdsaas"
6768
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/secretsmanager"
6869
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/transitgateway"
6970
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/usagereports"
@@ -1387,6 +1388,10 @@ func Provider() *schema.Provider {
13871388
"ibm_cdn": classicinfrastructure.ResourceIBMCDN(),
13881389
"ibm_hardware_firewall_shared": classicinfrastructure.ResourceIBMFirewallShared(),
13891390

1391+
// Software Defined Storage as a Service
1392+
"ibm_sds_volume": sdsaas.ResourceIBMSdsVolume(),
1393+
"ibm_sds_host": sdsaas.ResourceIBMSdsHost(),
1394+
13901395
// Partner Center Sell
13911396
"ibm_onboarding_registration": partnercentersell.ResourceIbmOnboardingRegistration(),
13921397
"ibm_onboarding_product": partnercentersell.ResourceIbmOnboardingProduct(),
@@ -2181,6 +2186,10 @@ func Validator() validate.ValidatorDict {
21812186

21822187
// Added for Logs Router Service
21832188
"ibm_logs_router_tenant": logsrouting.ResourceIBMLogsRouterTenantValidator(),
2189+
2190+
// Added for Software Defined Storage as a Service
2191+
"ibm_sds_volume": sdsaas.ResourceIBMSdsVolumeValidator(),
2192+
"ibm_sds_host": sdsaas.ResourceIBMSdsHostValidator(),
21842193
},
21852194
DataSourceValidatorDictionary: map[string]*validate.ResourceValidator{
21862195
"ibm_is_subnet": vpc.DataSourceIBMISSubnetValidator(),

ibm/service/sdsaas/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Terraform IBM Provider
2+
<!-- markdownlint-disable MD026 -->
3+
This area is primarily for IBM provider contributors and maintainers. For information on _using_ Terraform and the IBM provider, see the links below.
4+
5+
6+
## Handy Links
7+
* [Find out about contributing](../../../CONTRIBUTING.md) to the IBM provider!
8+
* IBM Provider Docs: [Home](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs)
9+
* IBM Provider Docs: [One of the resources](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/sds_volume)
10+
* IBM API Docs: [IBM API Docs for block](https://cloud.ibm.com/apidocs/block-storage). [IBM API Docs for storage](https://cloud.ibm.com/apidocs/object-storage)
11+
* IBM SDK: [IBM SDK for software defined storage](https://github.com/IBM/sds-go-sdk/tree/master/sdsaasv1)

0 commit comments

Comments
 (0)