Skip to content

Commit 737ad63

Browse files
committed
add security attribute
1 parent cb74105 commit 737ad63

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ website/node_modules
2525
*.iml
2626
*.test
2727
*.iml
28+
*.vscode
2829

2930
website/vendor
3031

internal/elasticsearch/security/role.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ func ResourceRole() *schema.Resource {
126126
DiffSuppressFunc: utils.DiffJsonSuppress,
127127
Optional: true,
128128
},
129+
"allow_restricted_indices": {
130+
Description: "Include matching restricted indices in names parameter.",
131+
Type: schema.TypeBool,
132+
Optional: true,
133+
},
129134
},
130135
},
131136
},
@@ -269,6 +274,10 @@ func resourceSecurityRolePut(ctx context.Context, d *schema.ResourceData, meta i
269274
}
270275
newIndex.FieldSecurity = &fieldSecurity
271276
}
277+
278+
allowRestrictedIndices := index["allow_restricted_indices"].(bool)
279+
newIndex.AllowRestrictedIndices = &allowRestrictedIndices
280+
272281
indices[i] = newIndex
273282
}
274283
role.Indices = indices
@@ -392,6 +401,7 @@ func flattenIndicesData(indices *[]models.IndexPerms) []interface{} {
392401
oi["names"] = index.Names
393402
oi["privileges"] = index.Privileges
394403
oi["query"] = index.Query
404+
oi["allow_restricted_indices"] = index.AllowRestrictedIndices
395405

396406
if index.FieldSecurity != nil {
397407
fsec := make(map[string]interface{})

internal/elasticsearch/security/role_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ resource "elasticstack_elasticsearch_security_role" "test" {
5858
cluster = ["all"]
5959
6060
indices {
61-
names = ["index1", "index2"]
62-
privileges = ["all"]
61+
names = ["index1", "index2"]
62+
privileges = ["all"]
6363
}
6464
6565
applications {

internal/models/models.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ type Role struct {
2222
}
2323

2424
type IndexPerms struct {
25-
FieldSecurity *FieldSecurity `json:"field_security,omitempty"`
26-
Names []string `json:"names"`
27-
Privileges []string `json:"privileges"`
28-
Query *string `json:"query,omitempty"`
25+
FieldSecurity *FieldSecurity `json:"field_security,omitempty"`
26+
Names []string `json:"names"`
27+
Privileges []string `json:"privileges"`
28+
Query *string `json:"query,omitempty"`
29+
AllowRestrictedIndices *bool `json:"allow_restricted_indices,omitempty"`
2930
}
3031

3132
type FieldSecurity struct {

main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
provider "elasticstack" {
2+
elasticsearch {
3+
username = "elastic"
4+
password = "changeme"
5+
endpoints = ["http://localhost:9200"]
6+
}
7+
}
8+

0 commit comments

Comments
 (0)