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

feat(log_stream): support JSONOBJECT format #445

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion auth0/resource_auth0_log_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ func newLogStream() *schema.Resource {
Type: schema.TypeString,
Optional: true,
RequiredWith: []string{"sink.0.http_endpoint", "sink.0.http_authorization", "sink.0.http_content_type"},
Description: "HTTP Content Format can be JSONLINES or JSONARRAY",
Description: "HTTP Content Format can be JSONLINES, JSONARRAY or JSONOBJECT",
ValidateFunc: validation.StringInSlice([]string{
"JSONLINES",
"JSONARRAY",
"JSONOBJECT",
}, false),
},
"http_content_type": {
Expand Down
23 changes: 23 additions & 0 deletions auth0/resource_auth0_log_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ func TestAccLogStreamHTTP(t *testing.T) {
resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_authorization", "AKIAXXXXXXXXXXXXXXXX"),
),
},
{
Config: random.Template(testAccLogStreamHTTPConfigUpdateJsonObject, rand),
Check: resource.ComposeTestCheckFunc(
random.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "name", "Acceptance-Test-LogStream-http-{{.random}}", rand),
resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "type", "http"),
resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_endpoint", "https://example.com/webhook/logs"),
resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_type", "application/json; charset=utf-8"),
resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_content_format", "JSONOBJECT"),
resource.TestCheckResourceAttr("auth0_log_stream.my_log_stream", "sink.0.http_authorization", "AKIAXXXXXXXXXXXXXXXX"),
),
},
{
Config: random.Template(testAccLogStreamHTTPConfigUpdate, rand),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -111,6 +122,18 @@ resource "auth0_log_stream" "my_log_stream" {
}
}
`
const testAccLogStreamHTTPConfigUpdateJsonObject = `
resource "auth0_log_stream" "my_log_stream" {
name = "Acceptance-Test-LogStream-http-new-{{.random}}"
type = "http"
sink {
http_endpoint = "https://example.com/logs"
http_content_type = "application/json"
http_content_format = "JSONOBJECT"
http_authorization = "AKIAXXXXXXXXXXXXXXXX"
}
}
`
const testAccLogStreamHTTPConfigUpdateFormat = `
resource "auth0_log_stream" "my_log_stream" {
name = "Acceptance-Test-LogStream-http-{{.random}}"
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/log_stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ For "eventgrid" the following arguments are supported:
- `azure_partner_topic` - (Optional, Computed) Name of the Partner Topic to be used with Azure. Generally should not be specified.

For "http" the following arguments are supported:
- `http_content_format` - (Required) The format of data sent over HTTP. Options are "JSONLINES" or "JSONARRAY"
- `http_content_format` - (Required) The format of data sent over HTTP. Options are "JSONLINES", "JSONARRAY" or "JSONOBJECT"
- `http_content_type` - (Required) The ContentType header to send over HTTP. Common value is "application/json"
- `http_endpoint` - (Required) The HTTP endpoint to send streaming logs
- `http_authorization` - (Required) Sent in the HTTP "Authorization" header with each request
Expand Down
22 changes: 22 additions & 0 deletions example/log_stream/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
provider "auth0" {}

resource "auth0_log_stream" "example_http" {
name = "HTTP log stream"
type = "http"
sink {
http_endpoint = "https://example.com/logs"
http_content_type = "application/json"
http_content_format = "JSONOBJECT"
http_authorization = "AKIAXXXXXXXXXXXXXXXX"
}
}

resource "auth0_log_stream" "example_aws" {
name = "AWS Eventbridge"
type = "eventbridge"
status = "active"
sink {
aws_account_id = "my_account_id"
aws_region = "us-east-2"
}
}