From 8d5d710fb946844ac5742dc44b9a370f936dd8ad Mon Sep 17 00:00:00 2001 From: Roger Date: Mon, 2 Dec 2024 14:41:56 -0500 Subject: [PATCH 1/4] Update resource_splunk_configs_conf.go to support ':' and '/' characters in stanza of splunk_configs_conf resource This is required for creation of inputs using the Splunk Addon for AWS, which creates inputs with a name like: aws_sqs_based_s3://s3-bucket-name. Link to Splunk Addon for AWS: https://splunk.github.io/splunk-add-on-for-amazon-web-services/ --- splunk/resource_splunk_configs_conf.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/splunk/resource_splunk_configs_conf.go b/splunk/resource_splunk_configs_conf.go index b24194e2..16e001d1 100644 --- a/splunk/resource_splunk_configs_conf.go +++ b/splunk/resource_splunk_configs_conf.go @@ -32,7 +32,7 @@ func configsConf() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9_\-.]+/[a-zA-Z0-9_\-.]+`), "A '/' separated string consisting of {conf_file_name}/{stanza_name} ex. props/custom_stanza"), + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9_\-.]+/[a-zA-Z0-9_\-.:/]+`), "A '/' separated string consisting of {conf_file_name}/{stanza_name} ex. props/custom_stanza"), Description: `A '/' separated string consisting of {conf_file_name}/{stanza_name} ex. props/custom_stanza`, }, "acl": aclSchema(), From e7b8c70952d7c96bb5e691f6857df7899fb04fde Mon Sep 17 00:00:00 2001 From: Roger Date: Tue, 3 Dec 2024 10:00:46 -0500 Subject: [PATCH 2/4] Update resource_splunk_configs_conf_test.go to test special character test cases --- splunk/resource_splunk_configs_conf_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/splunk/resource_splunk_configs_conf_test.go b/splunk/resource_splunk_configs_conf_test.go index 09846842..e4c97b42 100644 --- a/splunk/resource_splunk_configs_conf_test.go +++ b/splunk/resource_splunk_configs_conf_test.go @@ -10,7 +10,7 @@ import ( const newConfigsConf = ` resource "splunk_configs_conf" "tftest-stanza" { - name = "tf_test/tftest_stanza" + name = "tf_test/sqs://tftest_stanza" variables = { "disabled": "false" "key": "value" @@ -20,7 +20,7 @@ resource "splunk_configs_conf" "tftest-stanza" { const updateConfigsConf = ` resource "splunk_configs_conf" "tftest-stanza" { - name = "tf_test/tftest_stanza" + name = "tf_test/sqs://tftest_stanza" variables = { "disabled": "false" "key": "new-value" From 811e38958f07c0a52cdf234ae6cf3855c2ed8b37 Mon Sep 17 00:00:00 2001 From: Roger Date: Thu, 5 Dec 2024 09:24:42 -0500 Subject: [PATCH 3/4] Separated out tests for special characters in resource_splunk_configs_conf_test.go --- splunk/resource_splunk_configs_conf_test.go | 57 ++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/splunk/resource_splunk_configs_conf_test.go b/splunk/resource_splunk_configs_conf_test.go index e4c97b42..e8e08043 100644 --- a/splunk/resource_splunk_configs_conf_test.go +++ b/splunk/resource_splunk_configs_conf_test.go @@ -10,7 +10,7 @@ import ( const newConfigsConf = ` resource "splunk_configs_conf" "tftest-stanza" { - name = "tf_test/sqs://tftest_stanza" + name = "tf_test/tftest_stanza" variables = { "disabled": "false" "key": "value" @@ -20,7 +20,7 @@ resource "splunk_configs_conf" "tftest-stanza" { const updateConfigsConf = ` resource "splunk_configs_conf" "tftest-stanza" { - name = "tf_test/sqs://tftest_stanza" + name = "tf_test/tftest_stanza" variables = { "disabled": "false" "key": "new-value" @@ -60,6 +60,59 @@ func TestAccCreateSplunkConfigsConf(t *testing.T) { }) } +const newConfigsConfSpecialChars = ` +resource "splunk_configs_conf" "tftest-stanza-special-chars" { + name = "tf_test/sqs://tftest_stanza_special_chars" + variables = { + "disabled": "false" + "key": "value" + } +} +` + +const updateConfigsConfSpecialChars = ` +resource "splunk_configs_conf" "tftest-stanza-special-chars" { + name = "tf_test/sqs://tftest_stanza_special_chars" + variables = { + "disabled": "false" + "key": "new-value" + } +} +` + +func TestAccCreateSplunkConfigsConf(t *testing.T) { + resourceName := "splunk_configs_conf.tftest-stanza-special-chars" + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + CheckDestroy: testAccSplunkConfigsConfDestroyResources, + Steps: []resource.TestStep{ + { + Config: newConfigsConfSpecialChars, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "variables.%", "2"), + resource.TestCheckResourceAttr(resourceName, "variables.key", "value"), + ), + }, + { + Config: updateConfigsConfSpecialChars, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "variables.%", "2"), + resource.TestCheckResourceAttr(resourceName, "variables.key", "new-value"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + + func testAccSplunkConfigsConfDestroyResources(s *terraform.State) error { client, err := newTestClient() if err != nil { From bc0bf9af08ce6d4d4133774ed66ec7ef88c4d34f Mon Sep 17 00:00:00 2001 From: Roger Date: Thu, 5 Dec 2024 17:12:22 -0500 Subject: [PATCH 4/4] Separated out tests for special characters in resource_splunk_configs Changed test function name so it's unique --- splunk/resource_splunk_configs_conf_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/splunk/resource_splunk_configs_conf_test.go b/splunk/resource_splunk_configs_conf_test.go index e8e08043..50dff922 100644 --- a/splunk/resource_splunk_configs_conf_test.go +++ b/splunk/resource_splunk_configs_conf_test.go @@ -80,7 +80,7 @@ resource "splunk_configs_conf" "tftest-stanza-special-chars" { } ` -func TestAccCreateSplunkConfigsConf(t *testing.T) { +func TestAccCreateSplunkConfigsConfSpecialChars(t *testing.T) { resourceName := "splunk_configs_conf.tftest-stanza-special-chars" resource.Test(t, resource.TestCase{ PreCheck: func() {