Skip to content

Commit d69ea2b

Browse files
authored
Merge pull request #335 from SumoLogic/krish-otlp-source-terraform
SUMO-182757: Terraform support for http otlp source
2 parents 3c51cd4 + 2953b48 commit d69ea2b

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

sumologic/resource_sumologic_http_source_test.go

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func TestAccSumologicHTTPSource_create(t *testing.T) {
1414
var httpSource HTTPSource
1515
var httpTraceSource HTTPSource
1616
var kinesisLogSource HTTPSource
17+
var httpOtlpSource HTTPSource
1718
var collector Collector
1819
cName := acctest.RandomWithPrefix("tf-acc-test")
1920
cDescription := acctest.RandomWithPrefix("tf-acc-test")
@@ -27,16 +28,20 @@ func TestAccSumologicHTTPSource_create(t *testing.T) {
2728
kName := acctest.RandomWithPrefix("tf-acc-test")
2829
kDescription := acctest.RandomWithPrefix("tf-acc-test")
2930
kCategory := acctest.RandomWithPrefix("tf-acc-test")
31+
oName := acctest.RandomWithPrefix("tf-acc-test")
32+
oDescription := acctest.RandomWithPrefix("tf-acc-test")
33+
oCategory := acctest.RandomWithPrefix("tf-acc-test")
3034
resourceName := "sumologic_http_source.http"
3135
tracingResourceName := "sumologic_http_source.traces"
3236
kinesisResourceName := "sumologic_http_source.kinesisLog"
37+
otlpResourceName := "sumologic_http_source.otlp"
3338
resource.Test(t, resource.TestCase{
3439
PreCheck: func() { testAccPreCheck(t) },
3540
Providers: testAccProviders,
3641
CheckDestroy: testAccCheckHTTPSourceDestroy,
3742
Steps: []resource.TestStep{
3843
{
39-
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory, kName, kDescription, kCategory),
44+
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory, kName, kDescription, kCategory, oName, oDescription, oCategory),
4045
Check: resource.ComposeTestCheckFunc(
4146
testAccCheckHTTPSourceExists(resourceName, &httpSource),
4247
testAccCheckHTTPSourceValues(&httpSource, sName, sDescription, sCategory),
@@ -46,6 +51,8 @@ func TestAccSumologicHTTPSource_create(t *testing.T) {
4651
testAccCheckHTTPSourceValues(&httpTraceSource, tName, tDescription, tCategory),
4752
testAccCheckHTTPSourceExists(kinesisResourceName, &kinesisLogSource),
4853
testAccCheckHTTPSourceValues(&kinesisLogSource, kName, kDescription, kCategory),
54+
testAccCheckHTTPSourceExists(otlpResourceName, &httpOtlpSource),
55+
testAccCheckHTTPSourceValues(&httpOtlpSource, oName, oDescription, oCategory),
4956
resource.TestCheckResourceAttrSet(resourceName, "id"),
5057
resource.TestCheckResourceAttrSet(resourceName, "url"),
5158
resource.TestCheckResourceAttr(resourceName, "name", sName),
@@ -64,6 +71,12 @@ func TestAccSumologicHTTPSource_create(t *testing.T) {
6471
resource.TestCheckResourceAttr(kinesisResourceName, "description", kDescription),
6572
resource.TestCheckResourceAttr(kinesisResourceName, "category", kCategory),
6673
resource.TestCheckResourceAttr(kinesisResourceName, "content_type", "KinesisLog"),
74+
resource.TestCheckResourceAttrSet(otlpResourceName, "id"),
75+
resource.TestCheckResourceAttrSet(otlpResourceName, "url"),
76+
resource.TestCheckResourceAttr(otlpResourceName, "name", oName),
77+
resource.TestCheckResourceAttr(otlpResourceName, "description", oDescription),
78+
resource.TestCheckResourceAttr(otlpResourceName, "category", oCategory),
79+
resource.TestCheckResourceAttr(otlpResourceName, "content_type", "Otlp"),
6780
),
6881
},
6982
},
@@ -74,6 +87,7 @@ func TestAccSumologicHTTPSource_update(t *testing.T) {
7487
var httpSource HTTPSource
7588
var httpTraceSource HTTPSource
7689
var kinesisLogSource HTTPSource
90+
var httpOtlpSource HTTPSource
7791
cName := acctest.RandomWithPrefix("tf-acc-test")
7892
cDescription := acctest.RandomWithPrefix("tf-acc-test")
7993
cCategory := acctest.RandomWithPrefix("tf-acc-test")
@@ -86,26 +100,32 @@ func TestAccSumologicHTTPSource_update(t *testing.T) {
86100
kName := acctest.RandomWithPrefix("tf-acc-test")
87101
kDescription := acctest.RandomWithPrefix("tf-acc-test")
88102
kCategory := acctest.RandomWithPrefix("tf-acc-test")
103+
oName := acctest.RandomWithPrefix("tf-acc-test")
104+
oDescription := acctest.RandomWithPrefix("tf-acc-test")
105+
oCategory := acctest.RandomWithPrefix("tf-acc-test")
89106
sNameUpdated := acctest.RandomWithPrefix("tf-acc-test")
90107
sDescriptionUpdated := acctest.RandomWithPrefix("tf-acc-test")
91108
sCategoryUpdated := acctest.RandomWithPrefix("tf-acc-test")
92109
resourceName := "sumologic_http_source.http"
93110
tracingResourceName := "sumologic_http_source.traces"
94111
kinesisResourceName := "sumologic_http_source.kinesisLog"
112+
otlpResourceName := "sumologic_http_source.otlp"
95113
resource.Test(t, resource.TestCase{
96114
PreCheck: func() { testAccPreCheck(t) },
97115
Providers: testAccProviders,
98116
CheckDestroy: testAccCheckHTTPSourceDestroy,
99117
Steps: []resource.TestStep{
100118
{
101-
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory, kName, kDescription, kCategory),
119+
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory, kName, kDescription, kCategory, oName, oDescription, oCategory),
102120
Check: resource.ComposeTestCheckFunc(
103121
testAccCheckHTTPSourceExists(resourceName, &httpSource),
104122
testAccCheckHTTPSourceValues(&httpSource, sName, sDescription, sCategory),
105123
testAccCheckHTTPSourceExists(tracingResourceName, &httpTraceSource),
106124
testAccCheckHTTPSourceValues(&httpTraceSource, tName, tDescription, tCategory),
107125
testAccCheckHTTPSourceExists(kinesisResourceName, &kinesisLogSource),
108126
testAccCheckHTTPSourceValues(&kinesisLogSource, kName, kDescription, kCategory),
127+
testAccCheckHTTPSourceExists(otlpResourceName, &httpOtlpSource),
128+
testAccCheckHTTPSourceValues(&httpOtlpSource, oName, oDescription, oCategory),
109129
resource.TestCheckResourceAttrSet(resourceName, "id"),
110130
resource.TestCheckResourceAttrSet(resourceName, "url"),
111131
resource.TestCheckResourceAttr(resourceName, "name", sName),
@@ -124,10 +144,16 @@ func TestAccSumologicHTTPSource_update(t *testing.T) {
124144
resource.TestCheckResourceAttr(kinesisResourceName, "description", kDescription),
125145
resource.TestCheckResourceAttr(kinesisResourceName, "category", kCategory),
126146
resource.TestCheckResourceAttr(kinesisResourceName, "content_type", "KinesisLog"),
147+
resource.TestCheckResourceAttrSet(otlpResourceName, "id"),
148+
resource.TestCheckResourceAttrSet(otlpResourceName, "url"),
149+
resource.TestCheckResourceAttr(otlpResourceName, "name", oName),
150+
resource.TestCheckResourceAttr(otlpResourceName, "description", oDescription),
151+
resource.TestCheckResourceAttr(otlpResourceName, "category", oCategory),
152+
resource.TestCheckResourceAttr(otlpResourceName, "content_type", "Otlp"),
127153
),
128154
},
129155
{
130-
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sNameUpdated, sDescriptionUpdated, sCategoryUpdated, tName, tDescription, tCategory, kName, kDescription, kCategory),
156+
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sNameUpdated, sDescriptionUpdated, sCategoryUpdated, tName, tDescription, tCategory, kName, kDescription, kCategory, oName, oDescription, oCategory),
131157
Check: resource.ComposeTestCheckFunc(
132158
testAccCheckHTTPSourceExists(resourceName, &httpSource),
133159
testAccCheckHTTPSourceValues(&httpSource, sNameUpdated, sDescriptionUpdated, sCategoryUpdated),
@@ -138,6 +164,7 @@ func TestAccSumologicHTTPSource_update(t *testing.T) {
138164
resource.TestCheckResourceAttr(resourceName, "category", sCategoryUpdated),
139165
resource.TestCheckResourceAttr(tracingResourceName, "content_type", "Zipkin"),
140166
resource.TestCheckResourceAttr(kinesisResourceName, "content_type", "KinesisLog"),
167+
resource.TestCheckResourceAttr(otlpResourceName, "content_type", "Otlp"),
141168
),
142169
},
143170
},
@@ -225,7 +252,7 @@ func testAccCheckHTTPSourceValues(httpSource *HTTPSource, name, description, cat
225252
}
226253
}
227254

228-
func testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory, kName, kDescription, kCategory string) string {
255+
func testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory, kName, kDescription, kCategory, oName, oDescription, oCategory string) string {
229256
return fmt.Sprintf(`
230257
resource "sumologic_collector" "test" {
231258
name = "%s"
@@ -256,5 +283,13 @@ resource "sumologic_http_source" "kinesisLog" {
256283
content_type = "KinesisLog"
257284
collector_id = "${sumologic_collector.test.id}"
258285
}
259-
`, cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory, kName, kDescription, kCategory)
286+
287+
resource "sumologic_http_source" "otlp" {
288+
name = "%s"
289+
description = "%s"
290+
category = "%s"
291+
content_type = "Otlp"
292+
collector_id = "${sumologic_collector.test.id}"
293+
}
294+
`, cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory, kName, kDescription, kCategory, oName, oDescription, oCategory)
260295
}

website/docs/r/http_source.html.markdown

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: |-
66
---
77

88
# sumologic_http_source
9-
Provides a [Sumologic HTTP source][1], [Sumologic HTTP Traces source][2] and [Sumologic Kinesis Log source][3]. To start using Traces contact your Sumo account representative to activate.
9+
Provides a [Sumologic HTTP source][1], [Sumologic HTTP Traces source][2], [Sumologic Kinesis Log source][3] and [Sumologic HTTP_OTLP_source][4]. To start using Traces contact your Sumo account representative to activate.
1010

1111
__IMPORTANT:__ The endpoint is stored in plain-text in the state. This is a potential security issue.
1212

@@ -40,6 +40,14 @@ resource "sumologic_http_source" "kinesisLog" {
4040
collector_id = "${sumologic_collector.test.id}"
4141
}
4242
43+
resource "sumologic_http_source" "http_otlp_source" {
44+
name = "HTTP OTLP"
45+
description = "My description"
46+
category = "my/source/category"
47+
content_type = "Otlp"
48+
collector_id = "${sumologic_collector.test.id}"
49+
}
50+
4351
resource "sumologic_collector" "collector" {
4452
name = "my-collector"
4553
description = "Just testing this"
@@ -51,7 +59,7 @@ resource "sumologic_collector" "collector" {
5159
In addition to the [Common Source Properties](https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs#common-source-properties), the following arguments are supported:
5260

5361
- `message_per_request` - (Optional) When set to `true`, will create one log message per HTTP request.
54-
- `content_type` - (Optional) When configuring a HTTP Traces Source, set this property to `Zipkin`. When configuring a Kinesis Logs Source, set this property to `KinesisLog`. This should only be used when creating a Traces or Kinesis Log source.
62+
- `content_type` - (Optional) When configuring a HTTP Traces Source, set this property to `Zipkin`. When configuring a Kinesis Logs Source, set this property to `KinesisLog`. When configuring a HTTP OTLP Source, set this property to `Otlp`. This should only be used when creating a Traces, Kinesis Log or HTTP OTLP source.
5563

5664
### See also
5765
* [Common Source Properties](https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs#common-source-properties)
@@ -78,3 +86,4 @@ terraform import sumologic_http_source.test my-test-collector/my-test-source
7886
[1]: https://help.sumologic.com/Send_Data/Sources/02Sources_for_Hosted_Collectors/HTTP_Source
7987
[2]: https://help.sumologic.com/Traces/HTTP_Traces_Source
8088
[3]: https://help.sumologic.com/03Send-Data/Sources/02Sources-for-Hosted-Collectors/Amazon-Web-Services/AWS_Kinesis_Firehose_for_Logs_Source
89+
[4]: https://help.sumologic.com/03Send-Data/Sources/02Sources-for-Hosted-Collectors/OTLP_HTTP_Source

0 commit comments

Comments
 (0)