Skip to content

Commit 673e8a3

Browse files
authored
Fix placement option (#56)
* Fix placement option * Update docs for placement_option
1 parent 2be4d79 commit 673e8a3

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

docs/resources/instance.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ resource "genesiscloud_instance" "example" {
4949
- `password` (String, Sensitive) The password to access the instance. Your password must have upper and lower chars, digits and length between 8-72. **Please Note**: Only one of `ssh_keys` or `password` can be provided. Password is less secure - we recommend you use an SSH key-pair.
5050
- If the value of this attribute changes, Terraform will destroy and recreate the resource.
5151
- The string length must be at least 16.
52-
- `placement_option` (String) The placement option identifier in which instances are physically located relative to each other within a zone.
52+
- `placement_option` (String) The placement option identifier in which instances are physically located relative to each other within a zone. For example A or B.
5353
- If the value of this attribute changes, Terraform will destroy and recreate the resource.
5454
- `security_group_ids` (Set of String) The security groups of the instance. If not provided will be set to the default security group.
5555
- `ssh_key_ids` (Set of String) The ssh keys of the instance.

internal/provider/instance_resource.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (r *InstanceResource) Schema(ctx context.Context, req resource.SchemaReques
122122
},
123123
}),
124124
"placement_option": resourceenhancer.Attribute(ctx, schema.StringAttribute{
125-
MarkdownDescription: "The placement option identifier in which instances are physically located relative to each other within a zone.",
125+
MarkdownDescription: "The placement option identifier in which instances are physically located relative to each other within a zone. For example A or B.",
126126
Optional: true,
127127
Computed: true,
128128
PlanModifiers: []planmodifier.String{
@@ -284,7 +284,10 @@ func (r *InstanceResource) Create(ctx context.Context, req resource.CreateReques
284284
}
285285

286286
body.Region = genesiscloud.Region(data.Region.ValueString())
287-
body.PlacementOption = pointer(data.PlacementOption.ValueString())
287+
288+
if !data.PlacementOption.IsNull() && !data.PlacementOption.IsUnknown() {
289+
body.PlacementOption = pointer(data.PlacementOption.ValueString())
290+
}
288291

289292
response, err := r.client.CreateInstanceWithResponse(ctx, body)
290293
if err != nil {

0 commit comments

Comments
 (0)