Skip to content

Commit 8e9a240

Browse files
Copilottobio
andauthored
Migrate elasticstack_elasticsearch_security_role resource to Plugin Framework (#1331)
* Initial plan * Implement Plugin Framework role resource structure and basic functionality Co-authored-by: tobio <444668+tobio@users.noreply.github.com> * Complete Plugin Framework role resource migration with documentation Co-authored-by: tobio <444668+tobio@users.noreply.github.com> * Address PR feedback: use jsontypes, remove redundant code, add helper functions Co-authored-by: tobio <444668+tobio@users.noreply.github.com> * Fix schema to use nested blocks and run acceptance tests successfully Co-authored-by: tobio <444668+tobio@users.noreply.github.com> * Fix IsNull vs IsKnown checks and reorganize attribute type definitions Co-authored-by: tobio <444668+tobio@users.noreply.github.com> * Fix tests * Remove old acceptance tests * RunAs * Remove old role resource * Tidy up diags * Field security should be a single nested block * Field security should be a block in indices Moving to an attribute is a breaking change with no benefit at the moment * Bump SDK test to 0.12.2 * Skip SDK test when unsupported --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tobio <444668+tobio@users.noreply.github.com> Co-authored-by: Toby Brain <toby.brain@elastic.co>
1 parent cd616fb commit 8e9a240

File tree

31 files changed

+1845
-808
lines changed

31 files changed

+1845
-808
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ alias = [
4040

4141
### Changes
4242

43+
- Migrate `elasticstack_elasticsearch_security_role` resource to Terraform Plugin Framework ([#1330](https://github.com/elastic/terraform-provider-elasticstack/pull/1330))
4344
- Fix an issue where the `elasticstack_fleet_output` resource would error due to inconsistent state after an ouptut was edited in the Kibana UI ([#1506](https://github.com/elastic/terraform-provider-elasticstack/pull/1506))
4445
- Allow `index` and `data_view_id` values to both be unknown during planning in `elasticstack_kibana_security_detection_rule` ([#1499](https://github.com/elastic/terraform-provider-elasticstack/pull/1499))
4546
- Support `.bedrock` and `.gen-ai` connectors ([#1467](https://github.com/elastic/terraform-provider-elasticstack/pull/1467))

docs/resources/elasticsearch_security_role.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "elasticstack_elasticsearch_security_role Resource - terraform-provider-elasticstack"
44
subcategory: "Security"
55
description: |-
6-
Adds and updates roles in the native realm. See the security API put role documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html for more details.
6+
Adds and updates roles in the native realm. See the role API documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html for more details.
77
---
88

99
# elasticstack_elasticsearch_security_role (Resource)
1010

11-
Adds and updates roles in the native realm. See the [security API put role documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html) for more details.
11+
Adds and updates roles in the native realm. See the [role API documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html) for more details.
1212

1313
## Example Usage
1414

@@ -57,7 +57,7 @@ output "role" {
5757
- `applications` (Block Set) A list of application privilege entries. (see [below for nested schema](#nestedblock--applications))
5858
- `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.
5959
- `description` (String) The description of the role.
60-
- `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))
60+
- `elasticsearch_connection` (Block List, Deprecated) Elasticsearch connection configuration block. (see [below for nested schema](#nestedblock--elasticsearch_connection))
6161
- `global` (String) An object defining global privileges.
6262
- `indices` (Block Set) A list of indices permissions entries. (see [below for nested schema](#nestedblock--indices))
6363
- `metadata` (String) Optional meta-data.
@@ -110,7 +110,7 @@ Required:
110110
Optional:
111111

112112
- `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.
113-
- `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))
113+
- `field_security` (Block, Optional) The document fields that the owners of the role have read access to. (see [below for nested schema](#nestedblock--indices--field_security))
114114
- `query` (String) A search query that defines the documents the owners of the role have read access to.
115115

116116
<a id="nestedblock--indices--field_security"></a>
@@ -134,7 +134,7 @@ Required:
134134

135135
Optional:
136136

137-
- `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))
137+
- `field_security` (Block, Optional) The document fields that the owners of the role have read access to. (see [below for nested schema](#nestedblock--remote_indices--field_security))
138138
- `query` (String) A search query that defines the documents the owners of the role have read access to.
139139

140140
<a id="nestedblock--remote_indices--field_security"></a>

internal/elasticsearch/security/api_key/acc_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ func TestAccResourceSecurityApiKeyWithRemoteIndices(t *testing.T) {
135135
AllowRestrictedIndices: utils.Pointer(false),
136136
}},
137137
RemoteIndices: []models.RemoteIndexPerms{{
138-
Clusters: []string{"*"},
139-
Names: []string{"index-a*"},
140-
Privileges: []string{"read"},
141-
AllowRestrictedIndices: utils.Pointer(true),
138+
Clusters: []string{"*"},
139+
IndexPerms: models.IndexPerms{
140+
Names: []string{"index-a*"},
141+
Privileges: []string{"read"},
142+
AllowRestrictedIndices: utils.Pointer(true),
143+
},
142144
}},
143145
},
144146
}

0 commit comments

Comments
 (0)