Skip to content

Commit 0d82651

Browse files
authored
Move Source schema settings to Source - Tracking Plan connection resource (#76)
1 parent 220ec6c commit 0d82651

18 files changed

+1119
-800
lines changed

CHANGELOG.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1-
## 0.1.0 (Unreleased)
1+
## 0.8.0 (November 16, 2023)
2+
**BREAKING CHANGE**
23

3-
FEATURES:
4+
Move Source schema settings configuration to `segment_source_tracking_plan_connection` resource. Also adds schema settings to Source data source.
5+
6+
## 0.7.0 (November 1, 2023)
7+
Support Insert Function instance resource.
8+
9+
## 0.6.0 (October 31, 2023)
10+
Adds support for Source schema settings in the Source resource. Also removes the description field from Labels fields in various resources since it is not populated and not likely to be used for configuration.
11+
12+
## 0.5.1 (October 27, 2023)
13+
Fixes an issue where Function setting type could not be set to `TEXT_MAP``.
14+
15+
## 0.5.0 (October 26, 2023)
16+
Adds support for Reverse ETL model resource.
17+
(Previously misreleased as 0.0.5)
18+
19+
## 0.4.0 (October 19, 2023)
20+
Adds support for Destination subscriptions and Source - Tracking Plan connection resources.
21+
22+
## 0.3.0 (October 16, 2023)
23+
Adds support for Profiles Warehouse and fixes nil pointer access issues with Destination metadata.
24+
25+
## 0.2.0 (October 13, 2023)
26+
Adds support for destination filters and functions.
27+
28+
## 0.1.0 (October 6, 2023)
29+
Adds support for IAM resource (users, user groups)
30+
31+
## 0.0.2 (September 22, 2023)
32+
Initial release

docs/resources/label.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "segment_label Resource - terraform-provider-segment"
44
subcategory: ""
55
description: |-
6-
A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'
6+
A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'.
77
---
88

99
# segment_label (Resource)
1010

11-
A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'
11+
A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'.
1212

1313
## Example Usage
1414

docs/resources/source.md

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,6 @@ resource "segment_source" "my_source" {
3131
},
3232
]
3333
}
34-
35-
resource "segment_source" "my_source_with_schema_settings" {
36-
slug = "my_source_slug"
37-
name = "My Source"
38-
enabled = true
39-
metadata = {
40-
id = "abc123"
41-
}
42-
settings = jsonencode({
43-
"token" : "xyz321",
44-
})
45-
labels = [
46-
{
47-
key = "env"
48-
value = "dev"
49-
},
50-
]
51-
schema_settings = {
52-
forwarding_blocked_events_to = segment_source.my_source.id
53-
track = {
54-
allow_unplanned_events = true
55-
allow_unplanned_event_properties = true
56-
allow_event_on_violations = false
57-
allow_properties_on_violations = true
58-
common_event_on_violations = "ALLOW"
59-
}
60-
identify = {
61-
allow_traits_on_violations = false
62-
allow_unplanned_traits = false
63-
common_event_on_violations = "ALLOW"
64-
}
65-
group = {
66-
allow_traits_on_violations = true
67-
allow_unplanned_traits = true
68-
common_event_on_violations = "ALLOW"
69-
}
70-
}
71-
}
7234
```
7335

7436
<!-- schema generated by tfplugindocs -->
@@ -85,7 +47,6 @@ resource "segment_source" "my_source_with_schema_settings" {
8547

8648
- `labels` (Attributes Set) A list of labels applied to the Source. (see [below for nested schema](#nestedatt--labels))
8749
- `name` (String) The name of the Source.
88-
- `schema_settings` (Attributes) The schema settings associated with the Source. Upon import, this field will be empty even if the settings have already been configured due to Terraform limitations, but will be populated on the first apply. Fields not present in the config will not be managed by Terraform. (see [below for nested schema](#nestedatt--schema_settings))
8950

9051
### Read-Only
9152

@@ -141,46 +102,3 @@ Required:
141102

142103
- `key` (String) The key that represents the name of this label.
143104
- `value` (String) The value associated with the key of this label.
144-
145-
146-
<a id="nestedatt--schema_settings"></a>
147-
### Nested Schema for `schema_settings`
148-
149-
Optional:
150-
151-
- `forwarding_blocked_events_to` (String) Source id to forward blocked events to.
152-
- `forwarding_violations_to` (String) Source id to forward violations to.
153-
- `group` (Attributes) Group settings. (see [below for nested schema](#nestedatt--schema_settings--group))
154-
- `identify` (Attributes) Identify settings. (see [below for nested schema](#nestedatt--schema_settings--identify))
155-
- `track` (Attributes) Track settings. (see [below for nested schema](#nestedatt--schema_settings--track))
156-
157-
<a id="nestedatt--schema_settings--group"></a>
158-
### Nested Schema for `schema_settings.group`
159-
160-
Optional:
161-
162-
- `allow_traits_on_violations` (Boolean) Enable to allow group traits on violations.
163-
- `allow_unplanned_traits` (Boolean) Enable to allow unplanned group traits.
164-
- `common_event_on_violations` (String) The common group event on violations.
165-
166-
167-
<a id="nestedatt--schema_settings--identify"></a>
168-
### Nested Schema for `schema_settings.identify`
169-
170-
Optional:
171-
172-
- `allow_traits_on_violations` (Boolean) Enable to allow identify traits on violations.
173-
- `allow_unplanned_traits` (Boolean) Enable to allow unplanned identify traits.
174-
- `common_event_on_violations` (String) The common identify event on violations.
175-
176-
177-
<a id="nestedatt--schema_settings--track"></a>
178-
### Nested Schema for `schema_settings.track`
179-
180-
Optional:
181-
182-
- `allow_event_on_violations` (Boolean) Allow track event on violations.
183-
- `allow_properties_on_violations` (Boolean) Enable to allow track properties on violations.
184-
- `allow_unplanned_event_properties` (Boolean) Enable to allow unplanned track event properties.
185-
- `allow_unplanned_events` (Boolean) Enable to allow unplanned track events.
186-
- `common_event_on_violations` (String) The common track event on violations.

docs/resources/source_tracking_plan_connection.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "segment_source_tracking_plan_connection Resource - terraform-provider-segment"
44
subcategory: ""
55
description: |-
6-
Represents a connection between a Source and a Tracking Plan
6+
Represents a connection between a Source and a Tracking Plan. To import a connection into Terraform, use the following format: 'sourceid:trackingplan_id'.
77
---
88

99
# segment_source_tracking_plan_connection (Resource)
1010

11-
Represents a connection between a Source and a Tracking Plan
11+
Represents a connection between a Source and a Tracking Plan. To import a connection into Terraform, use the following format: 'source_id:tracking_plan_id'.
1212

1313
## Example Usage
1414

@@ -17,6 +17,26 @@ Represents a connection between a Source and a Tracking Plan
1717
resource "segment_source_tracking_plan_connection" "example" {
1818
source_id = "abc123"
1919
tracking_plan_id = "xyz321"
20+
schema_settings = {
21+
forwarding_blocked_events_to = segment_source.my_source.id
22+
track = {
23+
allow_unplanned_events = true
24+
allow_unplanned_event_properties = true
25+
allow_event_on_violations = false
26+
allow_properties_on_violations = true
27+
common_event_on_violations = "ALLOW"
28+
}
29+
identify = {
30+
allow_traits_on_violations = false
31+
allow_unplanned_traits = false
32+
common_event_on_violations = "ALLOW"
33+
}
34+
group = {
35+
allow_traits_on_violations = true
36+
allow_unplanned_traits = true
37+
common_event_on_violations = "ALLOW"
38+
}
39+
}
2040
}
2141
```
2242

@@ -27,3 +47,49 @@ resource "segment_source_tracking_plan_connection" "example" {
2747

2848
- `source_id` (String) The id of the Source.
2949
- `tracking_plan_id` (String) The id of the Tracking Plan.
50+
51+
### Optional
52+
53+
- `schema_settings` (Attributes) The schema settings associated with the Source. Upon import, this field will be empty even if the settings have already been configured due to Terraform limitations, but will be populated on the first apply. Fields not present in the config will not be managed by Terraform. (see [below for nested schema](#nestedatt--schema_settings))
54+
55+
<a id="nestedatt--schema_settings"></a>
56+
### Nested Schema for `schema_settings`
57+
58+
Optional:
59+
60+
- `forwarding_blocked_events_to` (String) Source id to forward blocked events to.
61+
- `forwarding_violations_to` (String) Source id to forward violations to.
62+
- `group` (Attributes) Group settings. (see [below for nested schema](#nestedatt--schema_settings--group))
63+
- `identify` (Attributes) Identify settings. (see [below for nested schema](#nestedatt--schema_settings--identify))
64+
- `track` (Attributes) Track settings. (see [below for nested schema](#nestedatt--schema_settings--track))
65+
66+
<a id="nestedatt--schema_settings--group"></a>
67+
### Nested Schema for `schema_settings.group`
68+
69+
Optional:
70+
71+
- `allow_traits_on_violations` (Boolean) Enable to allow group traits on violations.
72+
- `allow_unplanned_traits` (Boolean) Enable to allow unplanned group traits.
73+
- `common_event_on_violations` (String) The common group event on violations.
74+
75+
76+
<a id="nestedatt--schema_settings--identify"></a>
77+
### Nested Schema for `schema_settings.identify`
78+
79+
Optional:
80+
81+
- `allow_traits_on_violations` (Boolean) Enable to allow identify traits on violations.
82+
- `allow_unplanned_traits` (Boolean) Enable to allow unplanned identify traits.
83+
- `common_event_on_violations` (String) The common identify event on violations.
84+
85+
86+
<a id="nestedatt--schema_settings--track"></a>
87+
### Nested Schema for `schema_settings.track`
88+
89+
Optional:
90+
91+
- `allow_event_on_violations` (Boolean) Allow track event on violations.
92+
- `allow_properties_on_violations` (Boolean) Enable to allow track properties on violations.
93+
- `allow_unplanned_event_properties` (Boolean) Enable to allow unplanned track event properties.
94+
- `allow_unplanned_events` (Boolean) Enable to allow unplanned track events.
95+
- `common_event_on_violations` (String) The common track event on violations.

examples/resources/segment_source/resource.tf

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,3 @@ resource "segment_source" "my_source" {
1616
},
1717
]
1818
}
19-
20-
resource "segment_source" "my_source_with_schema_settings" {
21-
slug = "my_source_slug"
22-
name = "My Source"
23-
enabled = true
24-
metadata = {
25-
id = "abc123"
26-
}
27-
settings = jsonencode({
28-
"token" : "xyz321",
29-
})
30-
labels = [
31-
{
32-
key = "env"
33-
value = "dev"
34-
},
35-
]
36-
schema_settings = {
37-
forwarding_blocked_events_to = segment_source.my_source.id
38-
track = {
39-
allow_unplanned_events = true
40-
allow_unplanned_event_properties = true
41-
allow_event_on_violations = false
42-
allow_properties_on_violations = true
43-
common_event_on_violations = "ALLOW"
44-
}
45-
identify = {
46-
allow_traits_on_violations = false
47-
allow_unplanned_traits = false
48-
common_event_on_violations = "ALLOW"
49-
}
50-
group = {
51-
allow_traits_on_violations = true
52-
allow_unplanned_traits = true
53-
common_event_on_violations = "ALLOW"
54-
}
55-
}
56-
}

examples/resources/segment_source_tracking_plan_connection/resource.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,24 @@
22
resource "segment_source_tracking_plan_connection" "example" {
33
source_id = "abc123"
44
tracking_plan_id = "xyz321"
5+
schema_settings = {
6+
forwarding_blocked_events_to = segment_source.my_source.id
7+
track = {
8+
allow_unplanned_events = true
9+
allow_unplanned_event_properties = true
10+
allow_event_on_violations = false
11+
allow_properties_on_violations = true
12+
common_event_on_violations = "ALLOW"
13+
}
14+
identify = {
15+
allow_traits_on_violations = false
16+
allow_unplanned_traits = false
17+
common_event_on_violations = "ALLOW"
18+
}
19+
group = {
20+
allow_traits_on_violations = true
21+
allow_unplanned_traits = true
22+
common_event_on_violations = "ALLOW"
23+
}
24+
}
525
}

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ require (
1212
gotest.tools/gotestsum v1.11.0
1313
)
1414

15-
require github.com/bitfield/gotestdox v0.2.1 // indirect
15+
require (
16+
github.com/avast/retry-go/v4 v4.5.1 // indirect
17+
github.com/bitfield/gotestdox v0.2.1 // indirect
18+
)
1619

1720
require (
1821
github.com/Masterminds/goutils v1.1.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmms
1818
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
1919
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
2020
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
21+
github.com/avast/retry-go/v4 v4.5.1 h1:AxIx0HGi4VZ3I02jr78j5lZ3M6x1E0Ivxa6b0pUUh7o=
22+
github.com/avast/retry-go/v4 v4.5.1/go.mod h1:/sipNsvNB3RRuT5iNcb6h73nw3IBmXJ/H3XrCQYSOpc=
2123
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
2224
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
2325
github.com/bitfield/gotestdox v0.2.1 h1:Zj8IMLAO5/oiAKoMmtN96eyFiPZraJRTH2p0zDgtxc0=

internal/provider/label_resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (r *labelResource) Metadata(_ context.Context, req resource.MetadataRequest
5555

5656
func (r *labelResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
5757
resp.Schema = schema.Schema{
58-
Description: "A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'",
58+
Description: "A label associated with the current Workspace. To import a label into Terraform, use the following format: 'key:value'.",
5959
Attributes: map[string]schema.Attribute{
6060
"key": schema.StringAttribute{
6161
Description: "The key that represents the name of this label.",

internal/provider/misc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
package provider
22

33
const MaxPageSize = 200
4+
const DefaultRetryDelay = 1000

0 commit comments

Comments
 (0)