Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changelog/0.21.0.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@ title = "`oxide_ip_pool_silo_link`"
description = "The `id` attribute for the `oxide_ip_pool_silo_link` resource now uses the format `IP_POOL_ID/SILO_ID`, matching the `oxide_subnet_pool_silo_link` resource. [#794](https://github.com/oxidecomputer/terraform-provider-oxide/pull/794)"

[[enhancements]]
title = "Validate UUID Attributes"
description = "Attributes that expect UUIDs now validate whether their values are, in fact, valid UUIDs. This catches cases where names passed to attributes expecting UUIDs accidentally worked. [#795](https://github.com/oxidecomputer/terraform-provider-oxide/pull/795)."

[[bugs]]
title = "`oxide_ip_pool_silo_link`"
description = "The `silo_id` attribute now resolves to the silo's UUID, even if the attribute was previously configured by name. [#795](https://github.com/oxidecomputer/terraform-provider-oxide/pull/795)."

[[bugs]]
title = "`oxide_subnet_pool_silo_link`"
description = "The `silo_id` attribute now resolves to the silo's UUID, even if the attribute was previously configured by name. [#795](https://github.com/oxidecomputer/terraform-provider-oxide/pull/795)."
40 changes: 40 additions & 0 deletions docs/guides/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,46 @@ Refer to the
[changelog](https://github.com/oxidecomputer/terraform-provider-oxide/blob/main/CHANGELOG.md)
for a full list of changes.

## Upgrading to `0.21.0`

Release `0.21.0` contains breaking changes that require updates to Terraform
configuration files.

### UUID Validation

Attributes that expect UUIDs now validate whether their values are, in fact,
valid UUIDs. This catches cases where names passed to attributes expecting UUIDs
accidentally worked.

Terraform plans will fail with an `Invalid UUID` error on affected attributes.

```
│ Error: Invalid UUID
│ with oxide_ip_pool_silo_link.example,
│ on main.tf line 15, in resource "oxide_ip_pool_silo_link" "example":
│ 15: silo_id = "oxide"
│ Attribute silo_id value must be a valid UUID, got: oxide
```

Update the attribute to its UUID to comply with the validation.

```diff
--- main.tf
+++ main.tf
}

resource "oxide_ip_pool_silo_link" "example" {
- silo_id = "oxide"
+ silo_id = "338bfaf2-75d3-4a1c-8850-32173960f658"
ip_pool_id = "c6f8c195-8cee-40b5-bc95-7eb86edec285"
is_default = false
}
```

## Upgrading to `0.20.0`

Release `0.20.0` contains breaking changes that require updates to Terraform
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/anti_affinity_group/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/oxidecomputer/oxide.go/oxide"

"github.com/oxidecomputer/terraform-provider-oxide/internal/provider/shared"
oxidevalidator "github.com/oxidecomputer/terraform-provider-oxide/internal/provider/validator"
)

// Ensure the implementation satisfies the expected interfaces.
Expand Down Expand Up @@ -96,6 +97,9 @@ This resource manages anti-affinity groups.
"project_id": schema.StringAttribute{
Required: true,
Description: "ID of the project that will contain the anti-affinity group.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down
6 changes: 6 additions & 0 deletions internal/provider/disk/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/oxidecomputer/oxide.go/oxide"

"github.com/oxidecomputer/terraform-provider-oxide/internal/provider/shared"
oxidevalidator "github.com/oxidecomputer/terraform-provider-oxide/internal/provider/validator"
)

// Ensure the implementation satisfies the expected interfaces.
Expand Down Expand Up @@ -121,6 +122,9 @@ To create a blank disk it's necessary to set ''block_size''. Otherwise, one of '
"project_id": schema.StringAttribute{
Required: true,
Description: "ID of the project that will contain the disk.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down Expand Up @@ -150,6 +154,7 @@ To create a blank disk it's necessary to set ''block_size''. Otherwise, one of '
Optional: true,
Description: "Image ID of the disk source if applicable.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
stringvalidator.ConflictsWith(path.Expressions{
path.MatchRoot("block_size"),
}...),
Expand All @@ -165,6 +170,7 @@ To create a blank disk it's necessary to set ''block_size''. Otherwise, one of '
Optional: true,
Description: "Snapshot ID of the disk source if applicable.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
stringvalidator.ConflictsWith(path.Expressions{
path.MatchRoot("block_size"),
}...),
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/external_subnet/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/oxidecomputer/oxide.go/oxide"

"github.com/oxidecomputer/terraform-provider-oxide/internal/provider/shared"
oxidevalidator "github.com/oxidecomputer/terraform-provider-oxide/internal/provider/validator"
)

// Ensure the implementation satisfies the expected interfaces.
Expand Down Expand Up @@ -129,6 +130,9 @@ func (r *Resource) Schema(
"project_id": schema.StringAttribute{
Required: true,
Description: "Project ID where this external subnet is located.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down Expand Up @@ -168,6 +172,7 @@ func (r *Resource) Schema(
stringplanmodifier.UseStateForUnknown(),
},
Validators: []validator.String{
oxidevalidator.IsUUID(),
stringvalidator.ConflictsWith(path.MatchRoot("subnet")),
},
},
Expand Down
8 changes: 8 additions & 0 deletions internal/provider/external_subnet_attachment/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/oxidecomputer/oxide.go/oxide"

"github.com/oxidecomputer/terraform-provider-oxide/internal/provider/shared"
oxidevalidator "github.com/oxidecomputer/terraform-provider-oxide/internal/provider/validator"
)

// Ensure the implementation satisfies the expected interfaces.
Expand Down Expand Up @@ -98,13 +100,19 @@ func (r *Resource) Schema(
"external_subnet_id": schema.StringAttribute{
Required: true,
Description: "ID of the external subnet to attach.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"instance_id": schema.StringAttribute{
Required: true,
Description: "ID of the instance to attach the external subnet to.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/floating_ip/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/oxidecomputer/oxide.go/oxide"

"github.com/oxidecomputer/terraform-provider-oxide/internal/provider/shared"
oxidevalidator "github.com/oxidecomputer/terraform-provider-oxide/internal/provider/validator"
)

// ResourceModel represents the Terraform configuration and state for
Expand Down Expand Up @@ -144,6 +145,7 @@ This resource manages Oxide floating IPs.
stringplanmodifier.RequiresReplaceIfConfigured(),
},
Validators: []validator.String{
oxidevalidator.IsUUID(),
stringvalidator.ConflictsWith(path.MatchRoot("ip")),
stringvalidator.ConflictsWith(path.MatchRoot("ip_version")),
},
Expand All @@ -168,6 +170,9 @@ This resource manages Oxide floating IPs.
"project_id": schema.StringAttribute{
Required: true,
Description: "Project ID where this floating IP is located.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down
8 changes: 8 additions & 0 deletions internal/provider/image/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/oxidecomputer/oxide.go/oxide"

"github.com/oxidecomputer/terraform-provider-oxide/internal/provider/shared"
oxidevalidator "github.com/oxidecomputer/terraform-provider-oxide/internal/provider/validator"
)

// Ensure the implementation satisfies the expected interfaces.
Expand Down Expand Up @@ -111,6 +113,9 @@ This resource manages images.
"project_id": schema.StringAttribute{
Required: true,
Description: "ID of the project that will contain the image.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down Expand Up @@ -143,6 +148,9 @@ This resource manages images.
"source_snapshot_id": schema.StringAttribute{
Required: true,
Description: "Snapshot ID of the image source if applicable.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/images/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework-timeouts/datasource/timeouts"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/oxidecomputer/oxide.go/oxide"

"github.com/oxidecomputer/terraform-provider-oxide/internal/provider/shared"
oxidevalidator "github.com/oxidecomputer/terraform-provider-oxide/internal/provider/validator"
)

var (
Expand Down Expand Up @@ -92,6 +94,9 @@ Retrieve a list of all images belonging to a silo or project.
"project_id": schema.StringAttribute{
Optional: true,
Description: "ID of the project which contains the images.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
},
"id": schema.StringAttribute{
Computed: true,
Expand Down
12 changes: 12 additions & 0 deletions internal/provider/instance/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/oxidecomputer/oxide.go/oxide"

"github.com/oxidecomputer/terraform-provider-oxide/internal/provider/shared"
oxidevalidator "github.com/oxidecomputer/terraform-provider-oxide/internal/provider/validator"
)

// Ensure the implementation satisfies the expected interfaces.
Expand Down Expand Up @@ -242,6 +243,9 @@ This resource manages instances.
"project_id": schema.StringAttribute{
Required: true,
Description: "ID for the project containing this instance.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down Expand Up @@ -314,6 +318,7 @@ This resource manages instances.
Optional: true,
MarkdownDescription: "ID of the disk the instance should be booted from. Specifying a boot disk is optional but recommended to ensure predictable boot behavior. When provided, this ID must also be present in `disk_attachments`.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
stringvalidator.AlsoRequires(
path.MatchRoot("disk_attachments"),
),
Expand Down Expand Up @@ -379,6 +384,9 @@ This resource manages instances.
"subnet_id": schema.StringAttribute{
Required: true,
Description: "ID of the VPC subnet in which to create the instance network interface.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIf(
shared.RequiresReplaceUnlessEmptyStringOrNull(), "", "",
Expand All @@ -388,6 +396,9 @@ This resource manages instances.
"vpc_id": schema.StringAttribute{
Required: true,
Description: "ID of the VPC in which to create the instance network interface.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIf(
shared.RequiresReplaceUnlessEmptyStringOrNull(), "", "",
Expand Down Expand Up @@ -527,6 +538,7 @@ This resource manages instances.
Computed: true,
MarkdownDescription: "ID of the IP pool to allocate from. Conflicts with `ip_version`.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
stringvalidator.ConflictsWith(
path.MatchRelative().AtParent().AtName("ip_version"),
),
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/instance_external_ips/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework-timeouts/datasource/timeouts"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/oxidecomputer/oxide.go/oxide"

"github.com/oxidecomputer/terraform-provider-oxide/internal/provider/shared"
oxidevalidator "github.com/oxidecomputer/terraform-provider-oxide/internal/provider/validator"
)

var (
Expand Down Expand Up @@ -79,6 +81,9 @@ Retrieve information of all external IPs associated to an instance.
"instance_id": schema.StringAttribute{
Required: true,
Description: "ID of the instance to which the external IPs belong to.",
Validators: []validator.String{
oxidevalidator.IsUUID(),
},
},
"id": schema.StringAttribute{
Computed: true,
Expand Down
Loading
Loading