@@ -78,11 +78,11 @@ func resourceObjectGroup() *schema.Resource {
7878 ForceNew : false ,
7979 },
8080 "array_flatten_depth" : {
81- Type : schema .TypeInt ,
82- Default : 0 ,
83- Description : "Array flattening level. 0 - disabled, -1 - unlimited, >1 - the respective flattening level" ,
84- Optional : true ,
85- ForceNew : true ,
81+ Type : schema .TypeInt ,
82+ Default : 0 ,
83+ Description : "Array flattening level. 0 - disabled, -1 - unlimited, >1 - the respective flattening level" ,
84+ Optional : true ,
85+ ForceNew : true ,
8686 ValidateFunc : validation .IntAtLeast (- 1 ),
8787 },
8888 "column_renames" : {
@@ -95,6 +95,28 @@ func resourceObjectGroup() *schema.Resource {
9595 ForceNew : true ,
9696 Description : "A map specifying names of columns to rename (keys) and what to rename them to (values)" ,
9797 },
98+ "column_selection" : {
99+ Type : schema .TypeSet ,
100+ Elem : & schema.Resource {
101+ Schema : map [string ]* schema.Schema {
102+ "type" : {
103+ Type : schema .TypeString ,
104+ Required : true ,
105+ },
106+ "includes" : {
107+ Type : schema .TypeList ,
108+ Elem : & schema.Schema {
109+ Type : schema .TypeString ,
110+ },
111+ Required : true ,
112+ },
113+ },
114+
115+ },
116+ Optional : true ,
117+ ForceNew : true ,
118+ Description : "List of fields in logs to include or exclude from parsing. If nothing is specified, all fields will be parsed" ,
119+ },
98120
99121 // Workaround. Otherwise Terraform fails with "All fields are ForceNew or Computed w/out Optional, Update is superfluous"
100122 "description" : {
@@ -106,36 +128,45 @@ func resourceObjectGroup() *schema.Resource {
106128 }
107129}
108130
109-
110-
111131func resourceObjectGroupCreate (ctx context.Context , data * schema.ResourceData , meta interface {}) diag.Diagnostics {
112132 c := meta .(* ProviderMeta ).Client
113133
114134 // "unlimited" flattening represented as "null" in the api, and as -1 in the terraform module
115135 // because the terraform sdk doesn't support nil values in configs https://github.com/hashicorp/terraform-plugin-sdk/issues/261
116136 // We represent "null" as an int pointer to nil in the code.
117- array_flatten_tf := data .Get ("array_flatten_depth" ).(int )
118- var array_flatten_cs * int
119- if ( array_flatten_tf == - 1 ) {
137+ arrayFlattenTF := data .Get ("array_flatten_depth" ).(int )
138+ var arrayFlattenCS * int
139+ if arrayFlattenTF == - 1 {
120140 // -1 in terraform represents "null" in the ChaosSearch API call
121- array_flatten_cs = nil
141+ arrayFlattenCS = nil
122142 } else {
123143 // any other value is passed as is
124- array_flatten_cs = & array_flatten_tf
144+ arrayFlattenCS = & arrayFlattenTF
145+ }
146+ var columnSelection map [string ]interface {}
147+
148+ if data .Get ("column_selection" ).(* schema.Set ).Len () > 0 {
149+ columnSelectionInterfaces := data .Get ("column_selection" ).(* schema.Set ).List ()[0 ]
150+ columnSelectionInterface := columnSelectionInterfaces .(map [string ]interface {})
151+ columnSelection = map [string ]interface {}{
152+ "type" : columnSelectionInterface ["type" ].(string ),
153+ "includes" : columnSelectionInterface ["includes" ].([]interface {}),
154+ }
125155 }
126156
127157 createObjectGroupRequest := & client.CreateObjectGroupRequest {
128- Name : data .Get ("name" ).(string ),
129- SourceBucket : data .Get ("source_bucket" ).(string ),
130- FilterJSON : data .Get ("filter_json" ).(string ),
131- Format : data .Get ("format" ).(string ),
132- Compression : data .Get ("compression" ).(string ),
133- LiveEventsSqsArn : data .Get ("live_events_sqs_arn" ).(string ),
134- PartitionBy : data .Get ("partition_by" ).(string ),
135- Pattern : data .Get ("pattern" ).(string ),
136- IndexRetention : data .Get ("index_retention" ).(int ),
137- ArrayFlattenDepth : array_flatten_cs ,
138- ColumnRenames : data .Get ("column_renames" ).(map [string ]interface {}),
158+ Name : data .Get ("name" ).(string ),
159+ SourceBucket : data .Get ("source_bucket" ).(string ),
160+ FilterJSON : data .Get ("filter_json" ).(string ),
161+ Format : data .Get ("format" ).(string ),
162+ Compression : data .Get ("compression" ).(string ),
163+ LiveEventsSqsArn : data .Get ("live_events_sqs_arn" ).(string ),
164+ PartitionBy : data .Get ("partition_by" ).(string ),
165+ Pattern : data .Get ("pattern" ).(string ),
166+ IndexRetention : data .Get ("index_retention" ).(int ),
167+ ArrayFlattenDepth : arrayFlattenCS ,
168+ ColumnRenames : data .Get ("column_renames" ).(map [string ]interface {}),
169+ ColumnSelection : columnSelection ,
139170 }
140171
141172 if err := c .CreateObjectGroup (ctx , createObjectGroupRequest ); err != nil {
@@ -180,10 +211,12 @@ func resourceObjectGroupRead(ctx context.Context, data *schema.ResourceData, met
180211 data .Set ("pattern" , resp .Pattern )
181212 data .Set ("source_bucket" , resp .SourceBucket )
182213
214+ data .Set ("column_selection" , resp .ColumnSelection )
215+
183216 // "unlimited" flattening represented as "null" in the api, and as -1 in the terraform module
184217 // because the terraform sdk doesn't support nil values in configs https://github.com/hashicorp/terraform-plugin-sdk/issues/261
185218 // We represent "null" as an int pointer to nil in the code.
186- if ( resp .ArrayFlattenDepth == nil ) {
219+ if resp .ArrayFlattenDepth == nil {
187220 data .Set ("array_flatten_depth" , - 1 )
188221 } else {
189222 data .Set ("array_flatten_depth" , resp .ArrayFlattenDepth )
0 commit comments