Skip to content

Commit 6c8aa91

Browse files
authored
added doc fix and default value for volume attachment profile (IBM-Cloud#3080)
* added doc fix and default value for volume attachment profile * Update is_instance_volume_attachment.html.markdown * Update is_instance_volume_attachment.html.markdown
1 parent db4e9e8 commit 6c8aa91

File tree

2 files changed

+92
-44
lines changed

2 files changed

+92
-44
lines changed

ibm/resource_ibm_is_instance_volume_attachment.go

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ func resourceIBMISInstanceVolumeAttachment() *schema.Resource {
116116
Optional: true,
117117
ConflictsWith: []string{isInstanceVolAttVol},
118118
Computed: true,
119+
ValidateFunc: InvokeValidator("ibm_is_instance_volume_attachment", isInstanceVolProfile),
119120
Description: "The globally unique name for the volume profile to use for this volume.",
120121
},
122+
121123
isInstanceVolCapacity: {
122124
Type: schema.TypeInt,
123125
Optional: true,
@@ -222,6 +224,15 @@ func resourceIBMISInstanceVolumeAttachmentValidator() *ResourceValidator {
222224
MinValueLength: 1,
223225
MaxValueLength: 63})
224226

227+
validateSchema = append(validateSchema,
228+
ValidateSchema{
229+
Identifier: isInstanceVolProfile,
230+
ValidateFunctionIdentifier: ValidateAllowedStringValue,
231+
Type: TypeString,
232+
Optional: true,
233+
AllowedValues: "general-purpose, 5iops-tier, 10iops-tier, custom",
234+
})
235+
225236
ibmISInstanceVolumeAttachmentValidator := ResourceValidator{ResourceName: "ibm_is_instance_volume_attachment", Schema: validateSchema}
226237
return &ibmISInstanceVolumeAttachmentValidator
227238
}
@@ -250,17 +261,6 @@ func instanceVolAttachmentCreate(d *schema.ResourceData, meta interface{}, insta
250261
volProtoVol.Name = &volnamestr
251262
}
252263

253-
volProfileStr := "general-purpose"
254-
if volProfile, ok := d.GetOk(isInstanceVolProfile); ok {
255-
volProfileStr = volProfile.(string)
256-
volProtoVol.Profile = &vpcv1.VolumeProfileIdentity{
257-
Name: &volProfileStr,
258-
}
259-
} else {
260-
volProtoVol.Profile = &vpcv1.VolumeProfileIdentity{
261-
Name: &volProfileStr,
262-
}
263-
}
264264
volSnapshotStr := ""
265265
if volSnapshot, ok := d.GetOk(isInstanceVolumeSnapshot); ok {
266266
volSnapshotStr = volSnapshot.(string)
@@ -298,7 +298,24 @@ func instanceVolAttachmentCreate(d *schema.ResourceData, meta interface{}, insta
298298
if iops != 0 {
299299
volProtoVol.Iops = &iops
300300
}
301+
volProfileStr := "custom"
302+
volProtoVol.Profile = &vpcv1.VolumeProfileIdentity{
303+
Name: &volProfileStr,
304+
}
305+
} else {
306+
volProfileStr := "general-purpose"
307+
if volProfile, ok := d.GetOk(isInstanceVolProfile); ok {
308+
volProfileStr = volProfile.(string)
309+
volProtoVol.Profile = &vpcv1.VolumeProfileIdentity{
310+
Name: &volProfileStr,
311+
}
312+
} else {
313+
volProtoVol.Profile = &vpcv1.VolumeProfileIdentity{
314+
Name: &volProfileStr,
315+
}
316+
}
301317
}
318+
302319
instanceVolAttproto.Volume = volProtoVol
303320
}
304321

website/docs/r/is_instance_volume_attachment.html.markdown

Lines changed: 64 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,41 @@ resource "ibm_is_instance_volume_attachment" "testacc_att2" {
8686
}
8787
8888
```
89-
## Example usage (restoring using snapshot)
89+
## Example usage (creating new volume)
9090

9191
```terraform
9292
resource "ibm_is_instance_volume_attachment" "testacc_att3" {
9393
instance = ibm_is_instance.testacc_instance.id
9494
95-
name = "test-col-att-3"
95+
name = "test-col-att-3"
96+
iops = 100
97+
capacity = 50
98+
delete_volume_on_attachment_delete = true
99+
delete_volume_on_instance_delete = true
100+
volume_name = "testvol3"
101+
102+
//User can configure timeouts
103+
timeouts {
104+
create = "15m"
105+
update = "15m"
106+
delete = "15m"
107+
}
108+
}
109+
110+
```
111+
112+
## Example usage (restoring using snapshot)
113+
114+
```terraform
115+
resource "ibm_is_instance_volume_attachment" "testacc_att4" {
116+
instance = ibm_is_instance.testacc_instance.id
117+
118+
name = "test-col-att-4"
96119
profile = "general-purpose"
97120
snapshot = xxxx-xx-x-xxxxx
98121
delete_volume_on_attachment_delete = true
99122
delete_volume_on_instance_delete = true
100-
volume_name = "testvol3"
123+
volume_name = "testvol4"
101124
102125
//User can configure timeouts
103126
timeouts {
@@ -121,49 +144,57 @@ The `ibm_is_instance_volume_attachment` resource provides the following [[Timeou
121144
## Argument reference
122145
Review the argument references that you can specify for your resource.
123146

124-
- `capacity` - (Optional, Integer) The capacity of the volume in gigabytes.
147+
- `capacity` - (Optional, Integer) The capacity of the volume in gigabytes.
125148

126-
**NOTE**
127-
- The specified minimum and maximum capacity values for creating or updating volumes may expand in the future. Accepted value is in [10-16000].
128-
- If unspecified, the capacity will be the source snapshot's `minimum_capacity` when `snapshot` is provided.
129-
- Supports only expansion on update (must not be less than the current volume capacity)
130-
- Can be updated only if volume is attached to an running virtual server instance.
131-
- Stopped instance will be started on update of capacity of the volume.
149+
~> **NOTE**
150+
<ul>
151+
<li> The specified minimum and maximum capacity values for creating or updating volumes may expand in the future. Accepted value is in [10-16000].</li>
152+
<li> If unspecified, the capacity will be the source snapshot's `minimum_capacity` when `snapshot` is provided.</li>
153+
<li> Supports only expansion on update (must not be less than the current volume capacity)</li>
154+
<li> Can be updated only if volume is attached to an running virtual server instance.</li>
155+
<li> Stopped instance will be started on update of capacity of the volume.</li>
156+
</ul>
132157

133158
- `delete_volume_on_attachment_delete` - (Optional, Bool) If set to **true**, when deleting the attachment, the volume will also be deleted. By default it is **true**
134159
- `delete_volume_on_instance_delete` - (Optional, Bool) If set to **true**, when deleting the instance, the volume will also be deleted. By default it is **false**
135160
- `encryption_key` - (Optional, String) The CRN of the Key Protect Root Key or Hyper Protect Crypto Service Root Key for this resource. If this property is not provided but the image is encrypted, the image's encryption_key will be used. Otherwise, the encryption type for the volume will be `provider_managed`.
136161
- `instance` - (Required, String) The id of the instance.
137162
- `iops` - (Optional, Integer) The bandwidth for the new volume. This value is required for `custom` storage profiles only.
138-
**NOTE**
139-
- `iops` value can be upgraded and downgraged if volume is attached to an running virtual server instance. Stopped instances will be started on update of volume.
140-
- This table shows how storage size affects the `iops` ranges:
141-
142-
| Size range (GB) | IOPS range |
143-
|--------------------|----------------|
144-
| 10 - 39 | 100 - 1000 |
145-
| 40 - 79 | 100 - 2000 |
146-
| 80 - 99 | 100 - 4000 |
147-
| 100 - 499 | 100 - 6000 |
148-
| 500 - 999 | 100 - 10000 |
149-
| 1000 - 1999 | 100 - 20000 |
150-
| 2000 - 3999 | 100 - 40000 |
151-
| 4000 - 1999 | 100 - 40000 |
152-
| 8000 - 1999 | 100 - 48000 |
153-
| 10000 - 16000 | 100 - 48000 |
163+
164+
~> **NOTE**
165+
`iops` value can be upgraded and downgraged if volume is attached to an running virtual server instance. Stopped instances will be started on update of volume.
166+
- This table shows how storage size affects the `iops` ranges:
167+
168+
| Size range (GB) | IOPS range |
169+
|--------------------|----------------|
170+
| 10 - 39 | 100 - 1000 |
171+
| 40 - 79 | 100 - 2000 |
172+
| 80 - 99 | 100 - 4000 |
173+
| 100 - 499 | 100 - 6000 |
174+
| 500 - 999 | 100 - 10000 |
175+
| 1000 - 1999 | 100 - 20000 |
176+
| 2000 - 3999 | 100 - 40000 |
177+
| 4000 - 1999 | 100 - 40000 |
178+
| 8000 - 1999 | 100 - 48000 |
179+
| 10000 - 16000 | 100 - 48000 |
154180

155181
- `name` - (Required, String) The name of the volume attachment.
156182
- `profile` - (Optional, String) The globally unique name for this volume profile.
157183

158-
**NOTE**
159-
- tiered profiles [`general-purpose`, `5iops-tier`, `10iops-tier`] can be upgraded and downgraded into each other.
160-
- Can be applied only if volume is attached to an running virtual server instance.
161-
- Stopped instances will be started on update of volume.
184+
~> **NOTE**
185+
<ul>
186+
<li> Allowed values are : [`general-purpose`, `5iops-tier`, `10iops-tier`, `custom`].</li>
187+
<li> If `iops` is not present, `general-purpose` is taken as the volume profile.</li>
188+
<li> If `iops` is present, `custom` is taken as the volume profile.</li>
189+
Tiered profiles [`general-purpose`, `5iops-tier`, `10iops-tier`] can be upgraded and downgraded into each other.</li>
190+
<li> Can be updated only if volume is attached to an running virtual server instance.</li>
191+
<li> Stopped instances will be started on update of volume.</li></ul>
162192
- `snapshot` - (Optional, String) The unique identifier for this snapshot from which to clone the new volume.
163193

164-
**NOTE**
165-
- one of `capacity` or `snapshot` must be present for volume creation
166-
- if `capacity` is not present or less than `minimum_capacity` of the snapshot, `minimum_cpacity` is taken as the volume capacity.
194+
~> **NOTE**
195+
<ul>
196+
<li> one of `capacity` or `snapshot` must be present for volume creation.</li>
197+
<li> If `capacity` is not present or less than `minimum_capacity` of the snapshot, `minimum_capacity` is taken as the volume capacity.</li></ul>
167198
- `volume` - (Optional, String) The unique identifier for the existing volume
168199
- `volume_name` - (Optional, String) The unique user-defined name for this new volume.
169200

0 commit comments

Comments
 (0)