Skip to content

Commit

Permalink
GATE-4075: Adds support for teams accounts protocol detection setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Borkenstein committed Jul 20, 2023
1 parent 2ec17d3 commit 24681d3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/resources/teams_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ resource defines configuration for secure web gateway.

```terraform
resource "cloudflare_teams_account" "example" {
account_id = "f037e56e89293a057740de681ac9abbe"
tls_decrypt_enabled = true
account_id = "f037e56e89293a057740de681ac9abbe"
tls_decrypt_enabled = true
protocol_detection_enabled = true
block_page {
footer_text = "hello"
Expand Down Expand Up @@ -79,6 +80,7 @@ resource "cloudflare_teams_account" "example" {
- `payload_log` (Block List, Max: 1) Configuration for DLP Payload Logging. (see [below for nested schema](#nestedblock--payload_log))
- `proxy` (Block List, Max: 1) Configuration block for specifying which protocols are proxied. (see [below for nested schema](#nestedblock--proxy))
- `tls_decrypt_enabled` (Boolean) Indicator that decryption of TLS traffic is enabled.
- `protocol_detection_enabled` (Boolean) Indicator that protocol detection is enabled.
- `url_browser_isolation_enabled` (Boolean) Safely browse websites in Browser Isolation through a URL.

### Read-Only
Expand Down
1 change: 1 addition & 0 deletions examples/resources/cloudflare_teams_account/resource.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
resource "cloudflare_teams_account" "example" {
account_id = "f037e56e89293a057740de681ac9abbe"
tls_decrypt_enabled = true
protocol_detection_enabled = true

block_page {
footer_text = "hello"
Expand Down
12 changes: 12 additions & 0 deletions internal/sdkv2provider/resource_cloudflare_teams_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ func resourceCloudflareTeamsAccountRead(ctx context.Context, d *schema.ResourceD
}
}

if configuration.Settings.ProtocolDetection != nil {
if err := d.Set("protocol_detection_enabled", configuration.Settings.ProtocolDetection.Enabled); err != nil {
return diag.FromErr(fmt.Errorf("error parsing account protocol detection enablement: %w", err))
}
}

if err := d.Set("activity_log_enabled", configuration.Settings.ActivityLog.Enabled); err != nil {
return diag.FromErr(fmt.Errorf("error parsing account activity log enablement: %w", err))
}
Expand Down Expand Up @@ -138,6 +144,12 @@ func resourceCloudflareTeamsAccountUpdate(ctx context.Context, d *schema.Resourc
updatedTeamsAccount.Settings.TLSDecrypt = &cloudflare.TeamsTLSDecrypt{Enabled: tlsDecrypt.(bool)}
}

//nolint:staticcheck
protocolDetection, ok := d.GetOkExists("protocol_detection_enabled")
if ok {
updatedTeamsAccount.Settings.ProtocolDetection = &cloudflare.TeamsProtocolDetection{Enabled: protocolDetection.(bool)}
}

//nolint:staticcheck
activtyLog, ok := d.GetOkExists("activity_log_enabled")
if ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestAccCloudflareTeamsAccountConfigurationBasic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, consts.AccountIDSchemaKey, accountID),
resource.TestCheckResourceAttr(name, "tls_decrypt_enabled", "true"),
resource.TestCheckResourceAttr(name, "protocol_detection_enabled", "true"),
resource.TestCheckResourceAttr(name, "activity_log_enabled", "true"),
resource.TestCheckResourceAttr(name, "fips.0.tls", "true"),
resource.TestCheckResourceAttr(name, "block_page.0.name", rnd),
Expand Down Expand Up @@ -63,6 +64,7 @@ func testAccCloudflareTeamsAccountBasic(rnd, accountID string) string {
resource "cloudflare_teams_account" "%[1]s" {
account_id = "%[2]s"
tls_decrypt_enabled = true
protocol_detection_enabled = true
activity_log_enabled = true
block_page {
name = "%[1]s"
Expand Down
5 changes: 5 additions & 0 deletions internal/sdkv2provider/schema_cloudflare_teams_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func resourceCloudflareTeamsAccountSchema() map[string]*schema.Schema {
Optional: true,
Description: "Indicator that decryption of TLS traffic is enabled.",
},
"protocol_detection_enabled": {
Type: schema.TypeBool,
Optional: true,
Description: "Indicator that protocol detection is enabled.",
},
"activity_log_enabled": {
Type: schema.TypeBool,
Optional: true,
Expand Down

0 comments on commit 24681d3

Please sign in to comment.