@@ -17,8 +17,14 @@ import (
1717
1818var validateStatefulRuleSource = validation .StringInSlice ([]string {"awscloudtrail_stateful" }, false )
1919
20+ var validateStatefulRuleType = validation .StringInSlice ([]string {
21+ v2 .RuleTypeStatefulSequence ,
22+ v2 .RuleTypeStatefulCount ,
23+ v2 .RuleTypeStatefulUniqPercent ,
24+ }, false )
25+
2026func resourceSysdigSecureStatefulRule () * schema.Resource {
21- timeout := 5 * time .Minute
27+ timeout := 1 * time .Minute
2228
2329 return & schema.Resource {
2430 CreateContext : resourceSysdigRuleStatefulCreate ,
@@ -36,22 +42,23 @@ func resourceSysdigSecureStatefulRule() *schema.Resource {
3642 Delete : schema .DefaultTimeout (timeout ),
3743 },
3844
39- Schema : createRuleSchema (map [string ]* schema.Schema {
45+ Schema : map [string ]* schema.Schema {
46+ "name" : {
47+ Type : schema .TypeString ,
48+ Required : true ,
49+ ForceNew : true ,
50+ },
4051 "source" : {
4152 Type : schema .TypeString ,
4253 Optional : false ,
4354 Required : true ,
4455 ValidateDiagFunc : validateDiagFunc (validateStatefulRuleSource ),
4556 },
4657 "ruletype" : {
47- Type : schema .TypeString ,
48- Optional : false ,
49- Required : true ,
50- ValidateDiagFunc : validateDiagFunc (validation .StringInSlice ([]string {
51- v2 .RuleTypeStatefulSequence ,
52- v2 .StatefulCountRuleType ,
53- v2 .StatefulUniqPercentRuleType ,
54- }, false )),
58+ Type : schema .TypeString ,
59+ Optional : false ,
60+ Required : true ,
61+ ValidateDiagFunc : validateDiagFunc (validateStatefulRuleType ),
5562 },
5663 "append" : {
5764 Type : schema .TypeBool ,
@@ -75,7 +82,7 @@ func resourceSysdigSecureStatefulRule() *schema.Resource {
7582 },
7683 },
7784 },
78- }) ,
85+ },
7986 }
8087}
8188
@@ -95,8 +102,6 @@ func resourceSysdigRuleStatefulCreate(ctx context.Context, d *schema.ResourceDat
95102 if err != nil {
96103 return diag .FromErr (err )
97104 }
98- sysdigClients .AddCleanupHook (sendPoliciesToAgents )
99-
100105 d .SetId (strconv .Itoa (rule .ID ))
101106 _ = d .Set ("version" , rule .Version )
102107
@@ -147,12 +152,6 @@ func resourceSysdigRuleStatefulRead(ctx context.Context, d *schema.ResourceData,
147152 }
148153 }
149154
150- if rule .Details .Append != nil && ! (* (rule .Details .Append )) {
151- if rule .Details .Condition == nil {
152- return diag .Errorf ("no condition data for a Stateful rule" )
153- }
154- }
155-
156155 _ = d .Set ("name" , rule .Name )
157156 _ = d .Set ("source" , rule .Details .Source )
158157
@@ -202,7 +201,6 @@ func resourceSysdigRuleStatefulUpdate(ctx context.Context, d *schema.ResourceDat
202201 if err != nil {
203202 return diag .FromErr (err )
204203 }
205- sysdigClients .AddCleanupHook (sendPoliciesToAgents )
206204
207205 return nil
208206}
@@ -223,7 +221,6 @@ func resourceSysdigRuleStatefulDelete(ctx context.Context, d *schema.ResourceDat
223221 if err != nil {
224222 return diag .FromErr (err )
225223 }
226- sysdigClients .AddCleanupHook (sendPoliciesToAgents )
227224
228225 return nil
229226}
0 commit comments