Skip to content

Commit 094d97b

Browse files
committed
Add PlanModifiers for id fields
id fields aren't expected to change, so add PlanModifiers to use the state value.
1 parent 2892e1b commit 094d97b

File tree

6 files changed

+30
-0
lines changed

6 files changed

+30
-0
lines changed

internal/provider/application_resource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"github.com/hashicorp/terraform-plugin-framework/path"
1515
"github.com/hashicorp/terraform-plugin-framework/resource"
1616
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
17+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
18+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1719
"github.com/hashicorp/terraform-plugin-framework/types"
1820
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
1921
)
@@ -41,6 +43,9 @@ func (r *applicationResource) Schema(_ context.Context, _ resource.SchemaRequest
4143
Attributes: map[string]schema.Attribute{
4244
"id": schema.StringAttribute{
4345
Computed: true,
46+
PlanModifiers: []planmodifier.String{
47+
stringplanmodifier.UseStateForUnknown(),
48+
},
4449
},
4550
"name": schema.StringAttribute{
4651
Required: true,

internal/provider/certificate_template_resource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"github.com/hashicorp/terraform-plugin-framework/path"
1313
"github.com/hashicorp/terraform-plugin-framework/resource"
1414
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
15+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
16+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1517
"github.com/hashicorp/terraform-plugin-framework/types"
1618
)
1719

@@ -38,6 +40,9 @@ func (r *certificateTemplateResource) Schema(_ context.Context, _ resource.Schem
3840
Attributes: map[string]schema.Attribute{
3941
"id": schema.StringAttribute{
4042
Computed: true,
43+
PlanModifiers: []planmodifier.String{
44+
stringplanmodifier.UseStateForUnknown(),
45+
},
4146
},
4247
"name": schema.StringAttribute{
4348
Required: true,

internal/provider/plugin_resource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"github.com/hashicorp/terraform-plugin-framework/path"
1515
"github.com/hashicorp/terraform-plugin-framework/resource"
1616
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
17+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
18+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1719
"github.com/hashicorp/terraform-plugin-framework/types"
1820
)
1921

@@ -40,6 +42,9 @@ func (r *pluginResource) Schema(_ context.Context, _ resource.SchemaRequest, res
4042
Attributes: map[string]schema.Attribute{
4143
"id": schema.StringAttribute{
4244
Computed: true,
45+
PlanModifiers: []planmodifier.String{
46+
stringplanmodifier.UseStateForUnknown(),
47+
},
4348
},
4449
"type": schema.StringAttribute{
4550
Required: true,

internal/provider/registry_account_resource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"github.com/hashicorp/terraform-plugin-framework/path"
1313
"github.com/hashicorp/terraform-plugin-framework/resource"
1414
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
15+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
16+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1517
"github.com/hashicorp/terraform-plugin-framework/types"
1618
)
1719

@@ -38,6 +40,9 @@ func (r *registryAccountResource) Schema(_ context.Context, _ resource.SchemaReq
3840
Attributes: map[string]schema.Attribute{
3941
"id": schema.StringAttribute{
4042
Computed: true,
43+
PlanModifiers: []planmodifier.String{
44+
stringplanmodifier.UseStateForUnknown(),
45+
},
4146
},
4247
"name": schema.StringAttribute{
4348
Required: true,

internal/provider/service_account_resource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"github.com/hashicorp/terraform-plugin-framework/path"
1313
"github.com/hashicorp/terraform-plugin-framework/resource"
1414
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
15+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
16+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1517
"github.com/hashicorp/terraform-plugin-framework/types"
1618
)
1719

@@ -38,6 +40,9 @@ func (r *serviceAccountResource) Schema(_ context.Context, _ resource.SchemaRequ
3840
Attributes: map[string]schema.Attribute{
3941
"id": schema.StringAttribute{
4042
Computed: true,
43+
PlanModifiers: []planmodifier.String{
44+
stringplanmodifier.UseStateForUnknown(),
45+
},
4146
},
4247
"name": schema.StringAttribute{
4348
Required: true,

internal/provider/team_resource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"github.com/hashicorp/terraform-plugin-framework/path"
1313
"github.com/hashicorp/terraform-plugin-framework/resource"
1414
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
15+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
16+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1517
"github.com/hashicorp/terraform-plugin-framework/types"
1618
)
1719

@@ -38,6 +40,9 @@ func (r *teamResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
3840
Attributes: map[string]schema.Attribute{
3941
"id": schema.StringAttribute{
4042
Computed: true,
43+
PlanModifiers: []planmodifier.String{
44+
stringplanmodifier.UseStateForUnknown(),
45+
},
4146
},
4247
"name": schema.StringAttribute{
4348
Required: true,

0 commit comments

Comments
 (0)