Skip to content

Commit ec236a8

Browse files
Add Local Processing Agents (#323)
1 parent a2e8904 commit ec236a8

36 files changed

+1410
-15
lines changed

CHANGELOG.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.2.0...HEAD)
99

10-
## [1.2.0](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.1.26...v1.2.0)
10+
## [1.2.0](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.1.27...v1.2.0)
11+
12+
## Added
13+
- New resource `fivetran_local_processing_agent` that allows to manage Local Processing Agents.
14+
- New data source `fivetran_local_processing_agent` that allows to retrieve details of the existing Local Processing Agent for a given identifier.
15+
- New data source `fivetran_local_processing_agents` that allows to retrieve the list of existing Local Processing Agents available for the current account.
1116

1217
## Updated
18+
Updates to support management of local processing agents:
19+
- Resource `fivetran_connector` updates:
20+
- Added field `fivetran_connector.local_processing_agent_id`.
21+
22+
- Resource `fivetran_destination` updates:
23+
- Added field `fivetran_connector.local_processing_agent_id`.
24+
- Added field `fivetran_connector.networking_method`.
25+
26+
- Datasource `fivetran_connector` updates:
27+
- Added field `fivetran_connector.local_processing_agent_id`.
28+
29+
- Datasource `fivetran_destination` updates:
30+
- Added field `fivetran_connector.local_processing_agent_id`.
31+
- Added field `fivetran_connector.networking_method`.
32+
1333
- Resource `fivetran_connector_schema_config` reworked, added new validation logic and new field `validation_level`.
1434
- `fivetran_connector_schema_config.validation_level` allows to setup desired level of schema validation before apply
1535
- NONE: no validation needed, the fastest way to apply schema, especially for a newly created connector - it will use new [Create a Connector Schema Config](https://fivetran.com/docs/rest-api/connectors#createaconnectorschemaconfig) endpoint.

docs/data-sources/connector.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ data "fivetran_connector" "connector" {
3030
- `destination_schema` (Block, Read-only) (see [below for nested schema](#nestedblock--destination_schema))
3131
- `failed_at` (String) The timestamp of the time the connector sync failed last time.
3232
- `group_id` (String) The unique identifier for the Group (Destination) within the Fivetran system.
33+
- `local_processing_agent_id` (String) The local processing agent ID that refers to the controller created for the group the connection belongs to. If the value is specified, the system will try to associate the connection with an existing agent.
3334
- `name` (String) The name used both as the connector's name within the Fivetran system and as the source schema's name within your destination.
3435
- `networking_method` (String) Possible values: Directly, PrivateLink, SshTunnel, ProxyAgent.
3536
- `pause_after_trial` (Boolean) Specifies whether the connector should be paused after the free trial period has ended.

docs/data-sources/destination.md

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ data "fivetran_destination" "dest" {
2626
- `config` (Block, Read-only) (see [below for nested schema](#nestedblock--config))
2727
- `daylight_saving_time_enabled` (Boolean) Shift my UTC offset with daylight savings time (US Only)
2828
- `group_id` (String) The unique identifier for the Group within the Fivetran system.
29+
- `local_processing_agent_id` (String) The local processing agent ID that refers to the controller created for the group the connection belongs to. If the value is specified, the system will try to associate the connection with an existing agent.
30+
- `networking_method` (String) Possible values: Directly, PrivateLink, SshTunnel, ProxyAgent.
2931
- `region` (String) Data processing location. This is where Fivetran will operate and run computation on data.
3032
- `service` (String) The destination type id within the Fivetran system.
3133
- `setup_status` (String) Destination setup status.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
page_title: "Data Source: fivetran_local_processing_agent"
3+
---
4+
5+
# Data Source: fivetran_local_processing_agent
6+
7+
This data source returns a local processing agent object.
8+
9+
## Example Usage
10+
11+
```hcl
12+
data "fivetran_local_processing_agent" "local_processing_agent" {
13+
id = "local_processing_agent_id"
14+
}
15+
```
16+
17+
<!-- schema generated by tfplugindocs -->
18+
## Schema
19+
20+
### Required
21+
22+
- `id` (String) The unique identifier for the local processing agent within your account.
23+
24+
### Read-Only
25+
26+
- `display_name` (String) The unique name for the local processing agent.
27+
- `group_id` (String) The unique identifier for the Group within the Fivetran system.
28+
- `registered_at` (String) The timestamp of the time the local processing agent was created in your account.
29+
- `usage` (Attributes Set) (see [below for nested schema](#nestedatt--usage))
30+
31+
<a id="nestedatt--usage"></a>
32+
### Nested Schema for `usage`
33+
34+
Read-Only:
35+
36+
- `connection_id` (String) The unique identifier of the connection associated with the agent.
37+
- `schema` (String) The connection schema name.
38+
- `service` (String) The connection type.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
page_title: "Data Source: fivetran_local_processing_agents"
3+
---
4+
5+
# Data Source: fivetran_local_processing_agents
6+
7+
This data source returns a list of all local processing agents within your Fivetran account.
8+
9+
## Example Usage
10+
11+
```hcl
12+
data "fivetran_local_processing_agents" "local_processing_agents" {
13+
}
14+
```
15+
16+
<!-- schema generated by tfplugindocs -->
17+
## Schema
18+
19+
### Read-Only
20+
21+
- `items` (Attributes Set) (see [below for nested schema](#nestedatt--items))
22+
23+
<a id="nestedatt--items"></a>
24+
### Nested Schema for `items`
25+
26+
Required:
27+
28+
- `id` (String) The unique identifier for the local processing agent within your account.
29+
30+
Read-Only:
31+
32+
- `display_name` (String) The unique name for the local processing agent.
33+
- `group_id` (String) The unique identifier for the Group within the Fivetran system.
34+
- `registered_at` (String) The timestamp of the time the local processing agent was created in your account.
35+
- `usage` (Attributes Set) (see [below for nested schema](#nestedatt--items--usage))
36+
37+
<a id="nestedatt--items--usage"></a>
38+
### Nested Schema for `items.usage`
39+
40+
Read-Only:
41+
42+
- `connection_id` (String) The unique identifier of the connection associated with the agent.
43+
- `schema` (String) The connection schema name.
44+
- `service` (String) The connection type.

docs/resources/connector.md

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ resource "fivetran_connector" "amplitude" {
7070
- `auth` (Block, Optional) (see [below for nested schema](#nestedblock--auth))
7171
- `config` (Block, Optional) (see [below for nested schema](#nestedblock--config))
7272
- `destination_schema` (Block, Optional) (see [below for nested schema](#nestedblock--destination_schema))
73+
- `local_processing_agent_id` (String) The local processing agent ID that refers to the controller created for the group the connection belongs to. If the value is specified, the system will try to associate the connection with an existing agent.
7374
- `networking_method` (String) Possible values: Directly, PrivateLink, SshTunnel, ProxyAgent.
7475
- `proxy_agent_id` (String) The proxy agent ID.
7576
- `run_setup_tests` (Boolean) Specifies whether the setup tests should be run automatically. The default value is TRUE.

docs/resources/destination.md

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ resource "fivetran_destination" "dest" {
4444

4545
- `config` (Block, Optional) (see [below for nested schema](#nestedblock--config))
4646
- `daylight_saving_time_enabled` (Boolean) Shift my UTC offset with daylight savings time (US Only)
47+
- `local_processing_agent_id` (String) The local processing agent ID that refers to the controller created for the group the connection belongs to. If the value is specified, the system will try to associate the connection with an existing agent.
48+
- `networking_method` (String) Possible values: Directly, PrivateLink, SshTunnel, ProxyAgent.
4749
- `run_setup_tests` (Boolean) Specifies whether the setup tests should be run automatically. The default value is TRUE.
4850
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
4951
- `trust_certificates` (Boolean) Specifies whether we should trust the certificate automatically. The default value is FALSE. If a certificate is not trusted automatically, it has to be approved with [Certificates Management API Approve a destination certificate](https://fivetran.com/docs/rest-api/certificates#approveadestinationcertificate).
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
page_title: "Resource: fivetran_local_processing_agent"
3+
---
4+
5+
# Resource: fivetran_local_processing_agent
6+
7+
This resource allows you to create, update, and delete local processing agents.
8+
9+
## Example Usage
10+
11+
```hcl
12+
resource "fivetran_local_processing_agent" "test_lpa" {
13+
provider = fivetran-provider
14+
15+
display_name = "display_name"
16+
group_id = "group_id"
17+
}
18+
```
19+
20+
<!-- schema generated by tfplugindocs -->
21+
## Schema
22+
23+
### Required
24+
25+
- `display_name` (String) The unique name for the local processing agent.
26+
- `group_id` (String) The unique identifier for the Group within the Fivetran system.
27+
28+
### Optional
29+
30+
- `authentication_counter` (Number) Determines whether re-authentication needs to be performed.
31+
32+
### Read-Only
33+
34+
- `auth_json` (String) Base64-encoded content of the auth.json file.
35+
- `config_json` (String) Base64-encoded content of the config.json file.
36+
- `docker_compose_yaml` (String) Base64-encoded content of the compose file for the chosen containerization type.
37+
- `id` (String) The unique identifier for the local processing agent within your account.
38+
- `registered_at` (String) The timestamp of the time the local processing agent was created in your account.
39+
- `usage` (Attributes Set) (see [below for nested schema](#nestedatt--usage))
40+
41+
<a id="nestedatt--usage"></a>
42+
### Nested Schema for `usage`
43+
44+
Required:
45+
46+
- `schema` (String) The connection schema name.
47+
- `service` (String) The connection type.
48+
49+
Read-Only:
50+
51+
- `connection_id` (String) The unique identifier of the connection associated with the agent.

fivetran/framework/core/core.go

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ type SchemaField struct {
8686
Sensitive bool
8787

8888
DefaultString string
89-
9089
Readonly bool
9190
Description string
9291
}

fivetran/framework/core/model/connector.go

+19
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type ConnectorDatasourceModel struct {
3535

3636
ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
3737
NetworkingMethod types.String `tfsdk:"networking_method"`
38+
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
3839

3940
Status types.Object `tfsdk:"status"`
4041

@@ -123,6 +124,7 @@ type ConnectorResourceModel struct {
123124

124125
ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
125126
NetworkingMethod types.String `tfsdk:"networking_method"`
127+
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
126128

127129
Config types.Object `tfsdk:"config"`
128130
Auth types.Object `tfsdk:"auth"`
@@ -193,6 +195,12 @@ func (d *ConnectorResourceModel) ReadFromContainer(c ConnectorModelContainer, fo
193195
d.CreatedAt = types.StringValue(c.CreatedAt)
194196
d.GroupId = types.StringValue(c.GroupId)
195197
d.Service = types.StringValue(c.Service)
198+
199+
if c.LocalProcessingAgentId != "" {
200+
d.LocalProcessingAgentId = types.StringValue(c.LocalProcessingAgentId)
201+
} else {
202+
d.LocalProcessingAgentId = types.StringNull()
203+
}
196204

197205
d.DestinationSchema = getDestinationSchemaValue(c.Service, c.Schema)
198206

@@ -222,6 +230,12 @@ func (d *ConnectorDatasourceModel) ReadFromContainer(c ConnectorModelContainer)
222230
d.CreatedAt = types.StringValue(c.CreatedAt)
223231
d.GroupId = types.StringValue(c.GroupId)
224232
d.Service = types.StringValue(c.Service)
233+
234+
if c.LocalProcessingAgentId != "" {
235+
d.LocalProcessingAgentId = types.StringValue(c.LocalProcessingAgentId)
236+
} else {
237+
d.LocalProcessingAgentId = types.StringNull()
238+
}
225239

226240
d.DestinationSchema = getDestinationSchemaValue(c.Service, c.Schema)
227241

@@ -255,6 +269,7 @@ type ConnectorModelContainer struct {
255269

256270
ProxyAgentId string
257271
NetworkingMethod string
272+
LocalProcessingAgentId string
258273

259274
Config map[string]interface{}
260275

@@ -280,6 +295,10 @@ func (c *ConnectorModelContainer) ReadFromResponseData(data connectors.DetailsRe
280295
if data.NetworkingMethod != "" {
281296
c.NetworkingMethod = data.NetworkingMethod
282297
}
298+
299+
if data.LocalProcessingAgentId != "" {
300+
c.LocalProcessingAgentId = data.LocalProcessingAgentId
301+
}
283302
}
284303

285304
func getDestinatonSchemaForConfig(serviceId, nameAttr, tableAttr, prefixAttr attr.Value) (map[string]interface{}, error) {

fivetran/framework/core/model/destination.go

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ type destinationModel interface {
1212
SetTimeZonOffset(string)
1313
SetSetupStatus(string)
1414
SetDaylightSavingTimeEnabled(bool)
15+
SetLocalProcessingAgentId(string)
16+
SetNetworkingMethod(string)
1517
SetConfig(map[string]interface{})
1618
}
1719

@@ -23,5 +25,7 @@ func readFromResponse(d destinationModel, resp destinations.DestinationDetailsBa
2325
d.SetSetupStatus(resp.SetupStatus)
2426
d.SetTimeZonOffset(resp.TimeZoneOffset)
2527
d.SetDaylightSavingTimeEnabled(resp.DaylightSavingTimeEnabled)
28+
d.SetLocalProcessingAgentId(resp.LocalProcessingAgentId)
29+
d.SetNetworkingMethod(resp.NetworkingMethod)
2630
d.SetConfig(config)
2731
}

fivetran/framework/core/model/destination_datasource_model.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ type DestinationDatasourceModel struct {
1515
TimeZoneOffset types.String `tfsdk:"time_zone_offset"`
1616
SetupStatus types.String `tfsdk:"setup_status"`
1717
DaylightSavingTimeEnabled types.Bool `tfsdk:"daylight_saving_time_enabled"`
18+
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
19+
NetworkingMethod types.String `tfsdk:"networking_method"`
1820
Config types.Object `tfsdk:"config"`
1921
}
2022

@@ -41,7 +43,18 @@ func (d *DestinationDatasourceModel) SetSetupStatus(value string) {
4143
func (d *DestinationDatasourceModel) SetDaylightSavingTimeEnabled(value bool) {
4244
d.DaylightSavingTimeEnabled = types.BoolValue(value)
4345
}
44-
46+
func (d *DestinationDatasourceModel) SetLocalProcessingAgentId(value string) {
47+
if value != "" {
48+
d.LocalProcessingAgentId = types.StringValue(value)
49+
} else {
50+
d.LocalProcessingAgentId = types.StringNull()
51+
}
52+
}
53+
func (d *DestinationDatasourceModel) SetNetworkingMethod(value string) {
54+
if value != "" {
55+
d.NetworkingMethod = types.StringValue(value)
56+
}
57+
}
4558
func (d *DestinationDatasourceModel) SetConfig(value map[string]interface{}) {
4659
if d.Service.IsNull() || d.Service.IsUnknown() {
4760
panic("Service type is null. Can't handle config without service type.")

fivetran/framework/core/model/destination_resource_model.go

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type DestinationResourceModel struct {
1818
DaylightSavingTimeEnabled types.Bool `tfsdk:"daylight_saving_time_enabled"`
1919
Config types.Object `tfsdk:"config"`
2020
Timeouts timeouts.Value `tfsdk:"timeouts"`
21+
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
22+
NetworkingMethod types.String `tfsdk:"networking_method"`
2123

2224
RunSetupTests types.Bool `tfsdk:"run_setup_tests"`
2325
TrustCertificates types.Bool `tfsdk:"trust_certificates"`
@@ -47,6 +49,18 @@ func (d *DestinationResourceModel) SetSetupStatus(value string) {
4749
func (d *DestinationResourceModel) SetDaylightSavingTimeEnabled(value bool) {
4850
d.DaylightSavingTimeEnabled = types.BoolValue(value)
4951
}
52+
func (d *DestinationResourceModel) SetLocalProcessingAgentId(value string) {
53+
if value != "" {
54+
d.LocalProcessingAgentId = types.StringValue(value)
55+
} else {
56+
d.LocalProcessingAgentId = types.StringNull()
57+
}
58+
}
59+
func (d *DestinationResourceModel) SetNetworkingMethod(value string) {
60+
if value != "" {
61+
d.NetworkingMethod = types.StringValue(value)
62+
}
63+
}
5064
func (d *DestinationResourceModel) SetConfig(value map[string]interface{}) {
5165
if d.Service.IsNull() || d.Service.IsUnknown() {
5266
panic("Service type is null. Can't handle config without service type.")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package model
2+
3+
import (
4+
"github.com/fivetran/go-fivetran/local_processing_agent"
5+
)
6+
7+
type localProcessingAgentModel interface {
8+
SetId(string)
9+
SetDisplayName(string)
10+
SetGroupId(string)
11+
SetRegisteredAt(string)
12+
SetConfigJson(string)
13+
SetAuthJson(string)
14+
SetDockerComposeYaml(string)
15+
SetUsage([]localprocessingagent.LocalProcessingAgentUsageDetails)
16+
}
17+
18+
func readLocalProcessingAgentFromResponse(d localProcessingAgentModel, resp localprocessingagent.LocalProcessingAgentDetailsResponse) {
19+
d.SetId(resp.Data.Id)
20+
d.SetDisplayName(resp.Data.DisplayName)
21+
d.SetGroupId(resp.Data.GroupId)
22+
d.SetRegisteredAt(resp.Data.RegisteredAt)
23+
d.SetUsage(resp.Data.Usage)
24+
}
25+
26+
func readLocalProcessingAgentFromCreateResponse(d localProcessingAgentModel, resp localprocessingagent.LocalProcessingAgentCreateResponse) {
27+
d.SetId(resp.Data.Id)
28+
d.SetDisplayName(resp.Data.DisplayName)
29+
d.SetGroupId(resp.Data.GroupId)
30+
d.SetRegisteredAt(resp.Data.RegisteredAt)
31+
d.SetConfigJson(resp.Data.Files.ConfigJson)
32+
d.SetAuthJson(resp.Data.Files.AuthJson)
33+
d.SetDockerComposeYaml(resp.Data.Files.DockerComposeYaml)
34+
d.SetUsage(nil)
35+
}

0 commit comments

Comments
 (0)