Skip to content

Commit abe6434

Browse files
committed
feat(bare-metal): Remove CRN from resource creation and updation
1 parent 028cee5 commit abe6434

File tree

4 files changed

+11
-58
lines changed

4 files changed

+11
-58
lines changed

ibm/service/vpc/resource_ibm_is_bare_metal_server.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,6 @@ func ResourceIBMIsBareMetalServer() *schema.Resource {
11351135
},
11361136
"crn": {
11371137
Type: schema.TypeString,
1138-
Optional: true,
11391138
Computed: true,
11401139
Description: "The CRN for this trusted profile",
11411140
},
@@ -1513,23 +1512,15 @@ func resourceIBMISBareMetalServerCreate(context context.Context, d *schema.Resou
15131512
}
15141513
if targetIntf, ok := defaultTrustedProfileMap["target"]; ok {
15151514
targetMap := targetIntf.([]interface{})[0].(map[string]interface{})
1516-
var id, crn *string
1515+
var id *string
15171516
if idIntf, ok := targetMap["id"]; ok {
15181517
if idStr, ok := idIntf.(string); ok && idStr != "" {
15191518
id = &idStr
15201519
}
15211520
}
1522-
1523-
if crnIntf, ok := targetMap["crn"]; ok {
1524-
if crnStr, ok := crnIntf.(string); ok && crnStr != "" {
1525-
crn = &crnStr
1526-
}
1527-
}
1528-
1529-
if id != nil || crn != nil {
1521+
if id != nil {
15301522
defaultTrustedProfilePrototype.Target = &vpcv1.TrustedProfileIdentity{
15311523
ID: id,
1532-
CRN: crn,
15331524
}
15341525
}
15351526
}
@@ -2764,13 +2755,6 @@ func bareMetalServerUpdate(context context.Context, d *schema.ResourceData, meta
27642755
}
27652756
}
27662757

2767-
if d.HasChange("default_trusted_profile.0.target.0.crn") {
2768-
newTargetCRN := d.Get("default_trusted_profile.0.target.0.crn").(string)
2769-
defaultTrustedProfile.Target = &vpcv1.TrustedProfileIdentity{
2770-
CRN: &newTargetCRN,
2771-
}
2772-
}
2773-
27742758
if defaultTrustedProfile.AutoLink != nil || defaultTrustedProfile.Target != nil {
27752759
initializationPatch.DefaultTrustedProfile = defaultTrustedProfile
27762760
}

ibm/service/vpc/resource_ibm_is_bare_metal_server_initialization.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ func ResourceIBMIsBareMetalServerInitialization() *schema.Resource {
6464
},
6565
"crn": {
6666
Type: schema.TypeString,
67-
Optional: true,
6867
Computed: true,
6968
Description: "The CRN for this trusted profile",
7069
},
@@ -158,23 +157,15 @@ func resourceIBMISBareMetalServerInitializationCreate(context context.Context, d
158157

159158
if targetIntf, ok := defaultTrustedProfileMap["target"]; ok {
160159
targetMap := targetIntf.([]interface{})[0].(map[string]interface{})
161-
var id, crn *string
160+
var id *string
162161
if idIntf, ok := targetMap["id"]; ok {
163162
if idStr, ok := idIntf.(string); ok && idStr != "" {
164163
id = &idStr
165164
}
166165
}
167-
168-
if crnIntf, ok := targetMap["crn"]; ok {
169-
if crnStr, ok := crnIntf.(string); ok && crnStr != "" {
170-
crn = &crnStr
171-
}
172-
}
173-
174-
if id != nil || crn != nil {
166+
if id != nil {
175167
defaultTrustedProfilePrototype.Target = &vpcv1.TrustedProfileIdentity{
176-
ID: id,
177-
CRN: crn,
168+
ID: id,
178169
}
179170
}
180171
}

website/docs/r/is_bare_metal_server.markdown

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,8 @@ Review the argument references that you can specify for your resource.
238238
Nested scheme for `default_trusted_profile`:
239239
- `auto_link` - (Boolean) If set to true, the system will create a link to the specified target trusted profile during server creation. Regardless of whether a link is created by the system or manually using the IAM Identity service, it will be automatically deleted when the server is deleted.
240240
- `target` - (List) The default IAM trusted profile to use for this bare metal server.
241-
Nested `target` blocks have the following structure:
242-
- `id` - (String) The unique identifier for this trusted profile
243-
- `crn` - (String) The CRN for this trusted profile
241+
Nested scheme for `target`:
242+
- `id` - (String) The unique identifier for this trusted profile
244243
- `delete_type` - (Optional, String) Type of deletion on destroy. **soft** signals running operating system to quiesce and shutdown cleanly, **hard** immediately stop the server. By default its `hard`.
245244
- `enable_secure_boot` - (Optional, Boolean) Indicates whether secure boot is enabled. If enabled, the image must support secure boot or the server will fail to boot. Updating `enable_secure_boot` requires the server to be stopped and then it would be started.
246245
- `health_reasons` - (List) The reasons for the current health_state (if any).
@@ -263,26 +262,6 @@ Review the argument references that you can specify for your resource.
263262

264263
-> **NOTE:**
265264
To reinitialize a bare metal server, the server status must be stopped, or have failed a previous reinitialization. For more information, see [Managing Bare Metal Servers for VPC](https://cloud.ibm.com/docs/vpc?topic=vpc-managing-bare-metal-servers&interface=api#reinitialize-bare-metal-servers-api).
266-
267-
268-
- `default_trusted_profile`- (Optional, List) The default trusted profile to be used when initializing the bare metal server.
269-
270-
Nested scheme for `default_trusted_profile`:
271-
- `auto_link` - (Boolean) If set to true, the system will create a link to the specified target trusted profile during server creation. Regardless of whether a link is created by the system or manually using the IAM Identity service, it will be automatically deleted when the server is deleted.
272-
- `target` - (List) The default IAM trusted profile to use for this bare metal server.
273-
Nested `target` blocks have the following structure:
274-
- `id` - (String) The unique identifier for this trusted profile
275-
- `crn` - (String) The CRN for this trusted profile
276-
277-
278-
- `default_trusted_profile`- (Optional, List) The default trusted profile to be used when initializing the bare metal server.
279-
280-
Nested scheme for `default_trusted_profile`:
281-
- `auto_link` - (Boolean) If set to true, the system will create a link to the specified target trusted profile during server creation. Regardless of whether a link is created by the system or manually using the IAM Identity service, it will be automatically deleted when the server is deleted.
282-
- `target` - (List) The default IAM trusted profile to use for this bare metal server.
283-
Nested `target` blocks have the following structure:
284-
- `id` - (String) The unique identifier for this trusted profile
285-
- `crn` - (String) The CRN for this trusted profile
286265

287266
- `metadata_service`- (Optional, List) The metadata service configuration for the bare metal server.
288267

website/docs/r/is_bare_metal_server_initialization.markdown

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ resource "ibm_is_bare_metal_server_initialization" "initialization" {
3535
default_trusted_profile {
3636
auto_link = true
3737
target {
38-
id = "Profile-3a1dd8b4-db34-4281-88b2-42b194da30d6"
38+
id = var.profile_id
3939
}
4040
}
4141
}
@@ -44,7 +44,7 @@ resource "ibm_is_bare_metal_server_initialization" "initialization" {
4444
resource "ibm_is_bare_metal_server" "bms" {
4545
....
4646
lifecycle{
47-
ignore_changes = [ image, keys, user_data ]
47+
ignore_changes = [ image, keys, user_data, default_trusted_profile ]
4848
}
4949
}
5050
```
@@ -60,9 +60,8 @@ Review the argument references that you can specify for your resource.
6060
Nested scheme for `default_trusted_profile`:
6161
- `auto_link` - (Boolean) If set to true, the system will create a link to the specified target trusted profile during server creation. Regardless of whether a link is created by the system or manually using the IAM Identity service, it will be automatically deleted when the server is deleted.
6262
- `target` - (List) The default IAM trusted profile to use for this bare metal server.
63-
Nested `target` blocks have the following structure:
64-
- `id` - (String) The unique identifier for this trusted profile
65-
- `crn` - (String) The CRN for this trusted profile
63+
Nested scheme for `target`:
64+
- `id` - (String) The unique identifier for this trusted profile
6665
- `image` - (Required, String) Image id to use to reinitialize the bare metal server.
6766
- `keys` - (Required, Array) Keys ids to use to reinitialize the bare metal server.
6867
- `user_data` - (Optional, String) User data to transfer to the server bare metal server. If unspecified, no user data will be made available. (For reload/reinitialize provide the same user data as at the time of provisioning)

0 commit comments

Comments
 (0)