Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# A globalprotect log setting can be imported by providing the following base64 encoded object as the ID
# {
# location = {
# template = {
# name = "example-template"
# panorama_device = "localhost.localdomain"
# }
# }
#
# name = "example-gp-settings"
# }
terraform import panos_globalprotect_log_settings.example $(echo '{"location":{"template":{"name":"example-template","panorama_device":"localhost.localdomain"}},"name":"example-gp-settings"}' | base64)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
resource "panos_template" "example" {
location = { panorama = {} }
name = "example-template"
}

resource "panos_globalprotect_log_settings" "example" {
location = {
template = {
name = panos_template.example.name
}
}

name = "example-gp-settings"
description = "globalprotect log settings example"
filter = "(severity eq high)"
send_to_panorama = true

actions = [
{
name = "tag-action"
type = {
tagging = {
action = "add-tag"
target = "source-address"
tags = ["tag1", "tag2"]
registration = {
panorama = {}
}
}
}
}
]
}
120 changes: 120 additions & 0 deletions assets/terraform/test/resource_globalprotect_log_settings_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package provider_test

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-testing/config"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
"github.com/hashicorp/terraform-plugin-testing/statecheck"
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
)

func TestAccGlobalprotectLogSettings(t *testing.T) {
t.Parallel()

nameSuffix := acctest.RandStringFromCharSet(6, acctest.CharSetAlphaNum)
prefix := fmt.Sprintf("test-acc-%s", nameSuffix)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Config: globalprotectLogSettingsTmpl,
ConfigVariables: map[string]config.Variable{
"prefix": config.StringVariable(prefix),
"description": config.StringVariable("test description"),
"filter": config.StringVariable("(severity eq high)"),
"send_to_panorama": config.BoolVariable(true),
},
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(
"panos_globalprotect_log_settings.settings",
tfjsonpath.New("description"),
knownvalue.StringExact("test description"),
),
// statecheck.ExpectKnownValue(
// "panos_globalprotect_log_settings.settings",
// tfjsonpath.New("filter"),
// knownvalue.StringExact("(severity eq high)"),
// ),
statecheck.ExpectKnownValue(
"panos_globalprotect_log_settings.settings",
tfjsonpath.New("send_to_panorama"),
knownvalue.Bool(true),
),
},
},
{
Config: globalprotectLogSettingsTmpl,
ConfigVariables: map[string]config.Variable{
"prefix": config.StringVariable(prefix),
"description": config.StringVariable("updated description"),
"filter": config.StringVariable("(status eq 200)"),
"send_to_panorama": config.BoolVariable(false),
"actions": config.ListVariable(config.ObjectVariable(map[string]config.Variable{
"name": config.StringVariable("tag-action"),
"type": config.ObjectVariable(map[string]config.Variable{
"tagging": config.ObjectVariable(map[string]config.Variable{
"action": config.StringVariable("add-tag"),
"target": config.StringVariable("source-address"),
"tags": config.ListVariable(config.StringVariable("tag1"), config.StringVariable("tag2")),
}),
}),
})),
},
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(
"panos_globalprotect_log_settings.settings",
tfjsonpath.New("description"),
knownvalue.StringExact("updated description"),
),
// statecheck.ExpectKnownValue(
// "panos_globalprotect_log_settings.settings",
// tfjsonpath.New("filter"),
// knownvalue.StringExact("(severity eq critical)"),
// ),
statecheck.ExpectKnownValue(
"panos_globalprotect_log_settings.settings",
tfjsonpath.New("send_to_panorama"),
knownvalue.Bool(false),
),
statecheck.ExpectKnownValue(
"panos_globalprotect_log_settings.settings",
tfjsonpath.New("actions").AtSliceIndex(0).AtMapKey("name"),
knownvalue.StringExact("tag-action"),
),
},
},
},
})
}

const globalprotectLogSettingsTmpl = `
variable "prefix" { type = string }
variable "description" { type = string }
variable "filter" { type = string }
variable "send_to_panorama" { type = bool }
variable "actions" {
type = any
default = []
}


resource "panos_template" "tmpl" {
location = { panorama = {} }
name = var.prefix
}

resource "panos_globalprotect_log_settings" "settings" {
location = { template = { name = panos_template.tmpl.name } }
name = var.prefix
description = var.description
#filter = var.filter
send_to_panorama = var.send_to_panorama
actions = var.actions
}
`
Loading
Loading