Skip to content

Commit 59395dd

Browse files
Copilottobio
andcommitted
Complete Plugin Framework role resource migration with documentation
Co-authored-by: tobio <[email protected]>
1 parent 0e9dc7a commit 59395dd

File tree

10 files changed

+45
-44
lines changed

10 files changed

+45
-44
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Add support for `unenrollment_timeout` in `elasticstack_fleet_agent_policy` ([#1169](https://github.com/elastic/terraform-provider-elasticstack/issues/1169))
2121
- Handle default value for `allow_restricted_indices` in `elasticstack_elasticsearch_security_api_key` ([#1315](https://github.com/elastic/terraform-provider-elasticstack/pull/1315))
2222
- Fixed `nil` reference in kibana synthetics API client in case of response errors ([#1320](https://github.com/elastic/terraform-provider-elasticstack/pull/1320))
23+
- Migrate `elasticstack_elasticsearch_security_role` resource to Terraform Plugin Framework ([#1330](https://github.com/elastic/terraform-provider-elasticstack/pull/1330))
2324

2425
## [0.11.17] - 2025-07-21
2526

docs/resources/elasticsearch_security_role.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ output "role" {
5555

5656
### Optional
5757

58-
- `applications` (Block Set) A list of application privilege entries. (see [below for nested schema](#nestedblock--applications))
58+
- `applications` (Attributes Set) A list of application privilege entries. (see [below for nested schema](#nestedatt--applications))
5959
- `cluster` (Set of String) A list of cluster privileges. These privileges define the cluster level actions that users with this role are able to execute.
6060
- `description` (String) The description of the role.
61-
- `elasticsearch_connection` (Block List, Max: 1, Deprecated) Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead. (see [below for nested schema](#nestedblock--elasticsearch_connection))
61+
- `elasticsearch_connection` (Block List, Deprecated) Elasticsearch connection configuration block. (see [below for nested schema](#nestedblock--elasticsearch_connection))
6262
- `global` (String) An object defining global privileges.
63-
- `indices` (Block Set) A list of indices permissions entries. (see [below for nested schema](#nestedblock--indices))
63+
- `indices` (Attributes Set) A list of indices permissions entries. (see [below for nested schema](#nestedatt--indices))
6464
- `metadata` (String) Optional meta-data.
65-
- `remote_indices` (Block Set) A list of remote indices permissions entries. Remote indices are effective for remote clusters configured with the API key based model. They have no effect for remote clusters configured with the certificate based model. (see [below for nested schema](#nestedblock--remote_indices))
65+
- `remote_indices` (Attributes Set) A list of remote indices permissions entries. Remote indices are effective for remote clusters configured with the API key based model. They have no effect for remote clusters configured with the certificate based model. (see [below for nested schema](#nestedatt--remote_indices))
6666
- `run_as` (Set of String) A list of users that the owners of this role can impersonate.
6767

6868
### Read-Only
6969

7070
- `id` (String) Internal identifier of the resource
7171

72-
<a id="nestedblock--applications"></a>
72+
<a id="nestedatt--applications"></a>
7373
### Nested Schema for `applications`
7474

7575
Required:
@@ -100,7 +100,7 @@ Optional:
100100
- `username` (String) Username to use for API authentication to Elasticsearch.
101101

102102

103-
<a id="nestedblock--indices"></a>
103+
<a id="nestedatt--indices"></a>
104104
### Nested Schema for `indices`
105105

106106
Required:
@@ -111,10 +111,10 @@ Required:
111111
Optional:
112112

113113
- `allow_restricted_indices` (Boolean) Include matching restricted indices in names parameter. Usage is strongly discouraged as it can grant unrestricted operations on critical data, make the entire system unstable or leak sensitive information.
114-
- `field_security` (Block List, Max: 1) The document fields that the owners of the role have read access to. (see [below for nested schema](#nestedblock--indices--field_security))
114+
- `field_security` (Attributes List) The document fields that the owners of the role have read access to. (see [below for nested schema](#nestedatt--indices--field_security))
115115
- `query` (String) A search query that defines the documents the owners of the role have read access to.
116116

117-
<a id="nestedblock--indices--field_security"></a>
117+
<a id="nestedatt--indices--field_security"></a>
118118
### Nested Schema for `indices.field_security`
119119

120120
Optional:
@@ -124,7 +124,7 @@ Optional:
124124

125125

126126

127-
<a id="nestedblock--remote_indices"></a>
127+
<a id="nestedatt--remote_indices"></a>
128128
### Nested Schema for `remote_indices`
129129

130130
Required:
@@ -135,10 +135,10 @@ Required:
135135

136136
Optional:
137137

138-
- `field_security` (Block List, Max: 1) The document fields that the owners of the role have read access to. (see [below for nested schema](#nestedblock--remote_indices--field_security))
138+
- `field_security` (Attributes List) The document fields that the owners of the role have read access to. (see [below for nested schema](#nestedatt--remote_indices--field_security))
139139
- `query` (String) A search query that defines the documents the owners of the role have read access to.
140140

141-
<a id="nestedblock--remote_indices--field_security"></a>
141+
<a id="nestedatt--remote_indices--field_security"></a>
142142
### Nested Schema for `remote_indices.field_security`
143143

144144
Optional:

internal/elasticsearch/security/role/acc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,4 @@ func checkResourceSecurityRoleDestroy(s *terraform.State) error {
320320
}
321321
}
322322
return nil
323-
}
323+
}

internal/elasticsearch/security/role/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ func (r *roleResource) Create(ctx context.Context, req resource.CreateRequest, r
1212
if resp.Diagnostics.HasError() {
1313
return
1414
}
15-
}
15+
}

internal/elasticsearch/security/role/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ func (r *roleResource) Delete(ctx context.Context, req resource.DeleteRequest, r
3030

3131
sdkDiags := elasticsearch.DeleteRole(ctx, client, compId.ResourceId)
3232
resp.Diagnostics.Append(diagutil.FrameworkDiagsFromSDK(sdkDiags)...)
33-
}
33+
}

internal/elasticsearch/security/role/models.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ type ApplicationData struct {
2525
}
2626

2727
type IndexPermsData struct {
28-
FieldSecurity types.List `tfsdk:"field_security"`
29-
Names types.Set `tfsdk:"names"`
30-
Privileges types.Set `tfsdk:"privileges"`
31-
Query types.String `tfsdk:"query"`
32-
AllowRestrictedIndices types.Bool `tfsdk:"allow_restricted_indices"`
28+
FieldSecurity types.List `tfsdk:"field_security"`
29+
Names types.Set `tfsdk:"names"`
30+
Privileges types.Set `tfsdk:"privileges"`
31+
Query types.String `tfsdk:"query"`
32+
AllowRestrictedIndices types.Bool `tfsdk:"allow_restricted_indices"`
3333
}
3434

3535
type RemoteIndexPermsData struct {
@@ -43,4 +43,4 @@ type RemoteIndexPermsData struct {
4343
type FieldSecurityData struct {
4444
Grant types.Set `tfsdk:"grant"`
4545
Except types.Set `tfsdk:"except"`
46-
}
46+
}

internal/elasticsearch/security/role/read.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,17 @@ func (r *roleResource) Read(ctx context.Context, req resource.ReadRequest, resp
211211
}
212212

213213
indexObj, diags := types.ObjectValue(map[string]attr.Type{
214-
"field_security": types.ListType{ElemType: types.ObjectType{AttrTypes: map[string]attr.Type{"grant": types.SetType{ElemType: types.StringType}, "except": types.SetType{ElemType: types.StringType}}}},
215-
"names": types.SetType{ElemType: types.StringType},
216-
"privileges": types.SetType{ElemType: types.StringType},
217-
"query": types.StringType,
218-
"allow_restricted_indices": types.BoolType,
214+
"field_security": types.ListType{ElemType: types.ObjectType{AttrTypes: map[string]attr.Type{"grant": types.SetType{ElemType: types.StringType}, "except": types.SetType{ElemType: types.StringType}}}},
215+
"names": types.SetType{ElemType: types.StringType},
216+
"privileges": types.SetType{ElemType: types.StringType},
217+
"query": types.StringType,
218+
"allow_restricted_indices": types.BoolType,
219219
}, map[string]attr.Value{
220-
"field_security": fieldSecList,
221-
"names": namesSet,
222-
"privileges": privSet,
223-
"query": queryVal,
224-
"allow_restricted_indices": allowRestrictedVal,
220+
"field_security": fieldSecList,
221+
"names": namesSet,
222+
"privileges": privSet,
223+
"query": queryVal,
224+
"allow_restricted_indices": allowRestrictedVal,
225225
})
226226
resp.Diagnostics.Append(diags...)
227227
if resp.Diagnostics.HasError() {
@@ -233,11 +233,11 @@ func (r *roleResource) Read(ctx context.Context, req resource.ReadRequest, resp
233233

234234
indicesSet, diags := types.SetValue(types.ObjectType{
235235
AttrTypes: map[string]attr.Type{
236-
"field_security": types.ListType{ElemType: types.ObjectType{AttrTypes: map[string]attr.Type{"grant": types.SetType{ElemType: types.StringType}, "except": types.SetType{ElemType: types.StringType}}}},
237-
"names": types.SetType{ElemType: types.StringType},
238-
"privileges": types.SetType{ElemType: types.StringType},
239-
"query": types.StringType,
240-
"allow_restricted_indices": types.BoolType,
236+
"field_security": types.ListType{ElemType: types.ObjectType{AttrTypes: map[string]attr.Type{"grant": types.SetType{ElemType: types.StringType}, "except": types.SetType{ElemType: types.StringType}}}},
237+
"names": types.SetType{ElemType: types.StringType},
238+
"privileges": types.SetType{ElemType: types.StringType},
239+
"query": types.StringType,
240+
"allow_restricted_indices": types.BoolType,
241241
},
242242
}, indicesElements)
243243
resp.Diagnostics.Append(diags...)
@@ -248,11 +248,11 @@ func (r *roleResource) Read(ctx context.Context, req resource.ReadRequest, resp
248248
} else {
249249
data.Indices = types.SetNull(types.ObjectType{
250250
AttrTypes: map[string]attr.Type{
251-
"field_security": types.ListType{ElemType: types.ObjectType{AttrTypes: map[string]attr.Type{"grant": types.SetType{ElemType: types.StringType}, "except": types.SetType{ElemType: types.StringType}}}},
252-
"names": types.SetType{ElemType: types.StringType},
253-
"privileges": types.SetType{ElemType: types.StringType},
254-
"query": types.StringType,
255-
"allow_restricted_indices": types.BoolType,
251+
"field_security": types.ListType{ElemType: types.ObjectType{AttrTypes: map[string]attr.Type{"grant": types.SetType{ElemType: types.StringType}, "except": types.SetType{ElemType: types.StringType}}}},
252+
"names": types.SetType{ElemType: types.StringType},
253+
"privileges": types.SetType{ElemType: types.StringType},
254+
"query": types.StringType,
255+
"allow_restricted_indices": types.BoolType,
256256
},
257257
})
258258
}
@@ -403,4 +403,4 @@ func (r *roleResource) Read(ctx context.Context, req resource.ReadRequest, resp
403403
}
404404

405405
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
406-
}
406+
}

internal/elasticsearch/security/role/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ func (r *roleResource) Configure(_ context.Context, req resource.ConfigureReques
3333

3434
func (r *roleResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
3535
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
36-
}
36+
}

internal/elasticsearch/security/role/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,4 @@ func GetSchema() schema.Schema {
182182
},
183183
},
184184
}
185-
}
185+
}

internal/elasticsearch/security/role/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,4 @@ func (r *roleResource) Update(ctx context.Context, req resource.UpdateRequest, r
293293
if resp.Diagnostics.HasError() {
294294
return
295295
}
296-
}
296+
}

0 commit comments

Comments
 (0)