Skip to content

Commit

Permalink
GATE-2273: Adds support for device posture gateway rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Borkenstein committed Dec 21, 2021
1 parent 59bb5dc commit 186e972
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
43 changes: 24 additions & 19 deletions cloudflare/resource_cloudflare_teams_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func resourceCloudflareTeamsRuleRead(d *schema.ResourceData, meta interface{}) e
if err := d.Set("identity", rule.Identity); err != nil {
return fmt.Errorf("error parsing rule identity")
}
if err := d.Set("device_posture", rule.DevicePosture); err != nil {
return fmt.Errorf("error parsing rule device_posture")
}
if err := d.Set("version", int64(rule.Version)); err != nil {
return fmt.Errorf("error parsing rule version")
}
Expand All @@ -81,15 +84,16 @@ func resourceCloudflareTeamsRuleCreate(d *schema.ResourceData, meta interface{})
}

newTeamsRule := cloudflare.TeamsRule{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
Precedence: uint64(d.Get("precedence").(int)),
Enabled: d.Get("enabled").(bool),
Action: cloudflare.TeamsGatewayAction(d.Get("action").(string)),
Filters: filters,
Traffic: d.Get("traffic").(string),
Identity: d.Get("identity").(string),
Version: uint64(d.Get("version").(int)),
Name: d.Get("name").(string),
Description: d.Get("description").(string),
Precedence: uint64(d.Get("precedence").(int)),
Enabled: d.Get("enabled").(bool),
Action: cloudflare.TeamsGatewayAction(d.Get("action").(string)),
Filters: filters,
Traffic: d.Get("traffic").(string),
Identity: d.Get("identity").(string),
DevicePosture: d.Get("device_posture").(string),
Version: uint64(d.Get("version").(int)),
}

if settings != nil {
Expand Down Expand Up @@ -118,16 +122,17 @@ func resourceCloudflareTeamsRuleUpdate(d *schema.ResourceData, meta interface{})
}

teamsRule := cloudflare.TeamsRule{
ID: d.Id(),
Name: d.Get("name").(string),
Description: d.Get("description").(string),
Precedence: uint64(d.Get("precedence").(int)),
Enabled: d.Get("enabled").(bool),
Action: cloudflare.TeamsGatewayAction(d.Get("action").(string)),
Filters: filters,
Traffic: d.Get("traffic").(string),
Identity: d.Get("identity").(string),
Version: uint64(d.Get("version").(int)),
ID: d.Id(),
Name: d.Get("name").(string),
Description: d.Get("description").(string),
Precedence: uint64(d.Get("precedence").(int)),
Enabled: d.Get("enabled").(bool),
Action: cloudflare.TeamsGatewayAction(d.Get("action").(string)),
Filters: filters,
Traffic: d.Get("traffic").(string),
Identity: d.Get("identity").(string),
DevicePosture: d.Get("device_posture").(string),
Version: uint64(d.Get("version").(int)),
}

if settings != nil {
Expand Down
4 changes: 4 additions & 0 deletions cloudflare/schema_cloudflare_teams_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func resourceCloudflareTeamsRuleSchema() map[string]*schema.Schema {
Type: schema.TypeString,
Optional: true,
},
"device_posture": {
Type: schema.TypeString,
Optional: true,
},
"version": {
Type: schema.TypeInt,
Computed: true,
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/teams_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The following arguments are supported:
* `filters` - (Optional) The protocol or layer to evaluate the traffic and identity expressions.
* `traffic` - (Optional) The wirefilter expression to be used for traffic matching.
* `identity` - (Optional) The wirefilter expression to be used for identity matching.
* `device_posture` - (Optional) The wirefilter expression to be used for device_posture check matching.
* `rule_settings` - (Optional) Additional rule settings.

The **rule_settings** block supports:
Expand Down

0 comments on commit 186e972

Please sign in to comment.