Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Support the Sumo Logic log stream type #331

Merged
merged 2 commits into from
Mar 21, 2021
Merged
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
23 changes: 23 additions & 0 deletions auth0/resource_auth0_log_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func newLogStream() *schema.Resource {
"http",
"datadog",
"splunk",
"sumo",
}, true),
ForceNew: true,
Description: "Type of the log stream, which indicates the sink provider",
Expand Down Expand Up @@ -167,6 +168,11 @@ func newLogStream() *schema.Resource {
Default: nil,
RequiredWith: []string{"sink.0.splunk_domain", "sink.0.splunk_port", "sink.0.splunk_token"},
},
"sumo_source_address": {
Type: schema.TypeString,
Optional: true,
Default: nil,
},
},
},
},
Expand Down Expand Up @@ -258,6 +264,8 @@ func flattenLogStreamSink(d ResourceData, sink interface{}) []interface{} {
m = flattenLogStreamSinkDatadog(o)
case *management.LogStreamSinkSplunk:
m = flattenLogStreamSinkSplunk(o)
case *management.LogStreamSinkSumo:
m = flattenLogStreamSinkSumo(o)
}
return []interface{}{m}
}
Expand Down Expand Up @@ -304,6 +312,13 @@ func flattenLogStreamSinkSplunk(o *management.LogStreamSinkSplunk) interface{} {
"splunk_secure": o.GetSecure(),
}
}

func flattenLogStreamSinkSumo(o *management.LogStreamSinkSumo) interface{} {
return map[string]interface{}{
"sumo_source_address": o.GetSourceAddress(),
}
}

func expandLogStream(d ResourceData) *management.LogStream {

ls := &management.LogStream{
Expand Down Expand Up @@ -332,6 +347,8 @@ func expandLogStream(d ResourceData) *management.LogStream {
ls.Sink = expandLogStreamSinkDatadog(d)
case management.LogStreamTypeSplunk:
ls.Sink = expandLogStreamSinkSplunk(d)
case management.LogStreamTypeSumo:
ls.Sink = expandLogStreamSinkSumo(d)
default:
log.Printf("[WARN]: Unsupported log stream sink %s", s)
log.Printf("[WARN]: Raise an issue with the auth0 provider in order to support it:")
Expand Down Expand Up @@ -386,3 +403,9 @@ func expandLogStreamSinkSplunk(d ResourceData) *management.LogStreamSinkSplunk {
}
return o
}
func expandLogStreamSinkSumo(d ResourceData) *management.LogStreamSinkSumo {
o := &management.LogStreamSinkSumo{
SourceAddress: String(d, "sumo_source_address"),
}
return o
}
47 changes: 47 additions & 0 deletions auth0/resource_auth0_log_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,50 @@ resource "auth0_log_stream" "my_log_stream" {
}
}
`

func TestAccLogStreamSumo(t *testing.T) {
rand := random.String(6)

resource.Test(t, resource.TestCase{
Providers: map[string]terraform.ResourceProvider{
"auth0": Provider(),
},
Steps: []resource.TestStep{
{
Config: random.Template(logStreamSumoConfig, rand),
Check: resource.ComposeTestCheckFunc(
random.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "name", "Acceptance-Test-LogStream-sumo-{{.random}}", rand),
resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "type", "sumo"),
resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.sumo_source_address", "demo.sumo.com"),
),
},
{
Config: random.Template(logStreamSumoConfigUpdate, rand),
Check: resource.ComposeTestCheckFunc(
random.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "name", "Acceptance-Test-LogStream-sumo-{{.random}}", rand),
resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "type", "sumo"),
resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.sumo_source_address", "prod.sumo.com"),
),
},
},
})
}

const logStreamSumoConfig = `
resource "auth0_log_stream" "my_log_stream" {
name = "Acceptance-Test-LogStream-sumo-{{.random}}"
type = "sumo"
sink {
sumo_source_address = "demo.sumo.com"
}
}
`
const logStreamSumoConfigUpdate = `
resource "auth0_log_stream" "my_log_stream" {
name = "Acceptance-Test-LogStream-sumo-{{.random}}"
type = "sumo"
sink {
sumo_source_address = "prod.sumo.com"
}
}
`