Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Private Links #328

Merged
merged 21 commits into from
Nov 12, 2024
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
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,27 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.3.2...HEAD)
## [Unreleased](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.4.1...HEAD)

## [1.4.1](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.4.0...v1.4.1)

## Added
- New resource `fivetran_private_link` that allows to manage Private Links.
- New data source `fivetran_private_link` that allows to retrieve details of the existing Private Link for a given identifier.
- New data source `fivetran_private_links` that allows to retrieve the list of existing Private Links available for the current account.

Updates to support management of private links:
- Resource `fivetran_connector` updates:
- Added field `fivetran_connector.private_link_id`.

- Resource `fivetran_destination` updates:
- Added field `fivetran_destination.private_link_id`.

- Datasource `fivetran_connector` updates:
- Added field `fivetran_connector.private_link_id`.

- Datasource `fivetran_destination` updates:
- Added field `fivetran_destination.private_link_id`.

## [1.3.2](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.3.1...v1.3.2)

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ data "fivetran_connector" "connector" {
- `networking_method` (String) Possible values: Directly, SshTunnel, ProxyAgent.
- `pause_after_trial` (Boolean) Specifies whether the connector should be paused after the free trial period has ended.
- `paused` (Boolean) Specifies whether the connector is paused.
- `private_link_id` (String) The private link ID.
- `proxy_agent_id` (String) The proxy agent ID.
- `schedule_type` (String) The connector schedule configuration type. Supported values: auto, manual.
- `service` (String) The connector type id within the Fivetran system.
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/destination.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ data "fivetran_destination" "dest" {
- `group_id` (String) The unique identifier for the Group within the Fivetran system.
- `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.
- `networking_method` (String) Possible values: Directly, SshTunnel, ProxyAgent.
- `private_link_id` (String) The private link ID.
- `region` (String) Data processing location. This is where Fivetran will operate and run computation on data.
- `service` (String) The destination type id within the Fivetran system.
- `setup_status` (String) Destination setup status.
Expand Down
34 changes: 34 additions & 0 deletions docs/data-sources/private_link.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
page_title: "Data Source: fivetran_private_link"
---

# Data Source: fivetran_private_link

This data source returns a private link object.

## Example Usage

```hcl
data "fivetran_private_link" "private_link" {
id = "private_link_id"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) The unique identifier for the private link within the Fivetran system.

### Read-Only

- `cloud_provider` (String) The cloud provider name.
- `config_map` (Map of String) Configuration.
- `created_at` (String) The date and time the membership was created.
- `created_by` (String) The unique identifier for the User within the Fivetran system.
- `name` (String) The private link name within the account. The name must start with a letter or underscore and can only contain letters, numbers, or underscores. Maximum size of name is 23 characters.
- `region` (String) Data processing location. This is where Fivetran will operate and run computation on data.
- `service` (String) Service type.
- `state` (String) The state of the private link.
- `state_summary` (String) The state of the private link.
35 changes: 35 additions & 0 deletions docs/data-sources/private_links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fivetran_private_links Data Source - terraform-provider-fivetran"
subcategory: ""
description: |-

---

# fivetran_private_links (Data Source)





<!-- schema generated by tfplugindocs -->
## Schema

### Read-Only

- `items` (Block Set) (see [below for nested schema](#nestedblock--items))

<a id="nestedblock--items"></a>
### Nested Schema for `items`

Read-Only:

- `cloud_provider` (String) The cloud provider name.
- `created_at` (String) The date and time the membership was created.
- `created_by` (String) The unique identifier for the User within the Fivetran system.
- `id` (String) The unique identifier for the private link within the Fivetran system.
- `name` (String) The private link name within the account. The name must start with a letter or underscore and can only contain letters, numbers, or underscores. Maximum size of name is 23 characters.
- `region` (String) Data processing location. This is where Fivetran will operate and run computation on data.
- `service` (String) Service type.
- `state` (String) The state of the private link.
- `state_summary` (String) The state of the private link.
16 changes: 16 additions & 0 deletions docs/data-sources/private_links.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
page_title: "Data Source: fivetran_private_links"
---

# Data Source: fivetran_private_links

This data source returns a list of all private links within your Fivetran account.

## Example Usage

```hcl
data "fivetran_private_links" "private_links" {
}
```

{{ .SchemaMarkdown | trimspace }}
1 change: 1 addition & 0 deletions docs/resources/connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ resource "fivetran_connector" "amplitude" {
- `destination_schema` (Block, Optional) (see [below for nested schema](#nestedblock--destination_schema))
- `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.
- `networking_method` (String) Possible values: Directly, SshTunnel, ProxyAgent.
- `private_link_id` (String) The private link ID.
- `proxy_agent_id` (String) The proxy agent ID.
- `run_setup_tests` (Boolean) Specifies whether the setup tests should be run automatically. The default value is FALSE.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/connector_schema_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ resource "fivetran_connector_schema_config" "schema" {

### Optional

- `schema_change_handling` (String) The value specifying how new source data is handled.
- `schema` (Block Set, Deprecated) (see [below for nested schema](#nestedblock--schema))
- `schema_change_handling` (String) The value specifying how new source data is handled.
- `schemas` (Attributes Map) Map of schema configurations. (see [below for nested schema](#nestedatt--schemas))
- `schemas_json` (String) Schema settings in Json format, following Fivetran API endpoint contract for `schemas` field (a map of schemas).
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
Expand Down
1 change: 1 addition & 0 deletions docs/resources/destination.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ resource "fivetran_destination" "dest" {
- `daylight_saving_time_enabled` (Boolean) Shift my UTC offset with daylight savings time (US Only)
- `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.
- `networking_method` (String) Possible values: Directly, SshTunnel, ProxyAgent.
- `private_link_id` (String) The private link ID.
- `run_setup_tests` (Boolean) Specifies whether the setup tests should be run automatically. The default value is TRUE.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `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).
Expand Down
55 changes: 55 additions & 0 deletions docs/resources/private_link.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
page_title: "Resource: fivetran_private_link"
---

# Resource: fivetran_private_link

This resource allows you to create, update, and delete private links.

## Example Usage

```hcl
resource "fivetran_private_link" "test_pl" {
provider = fivetran-provider

name = "name"
region = "region"
service = "service"

config {
connection_service_name = "connection_service_name"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `config_map` (Map of String) Configuration.

#### Possible values
-- `connection_service_name` (String): The name of your connection service.
-- `account_url` (String): The URL of your account.
-- `vpce_id` (String): The ID of your Virtual Private Cloud Endpoint.
-- `aws_account_id` (String): The ID of your AWS account.
-- `cluster_identifier` (String): The cluster identifier.
-- `connection_service_id` (String): The ID of your connection service.
-- `workspace_url` (String): The URL of your workspace.
-- `pls_id` (String): The ID of your Azure Private Link service.
-- `sub_resource_name` (String): The name of subresource.
-- `private_dns_regions` (String): Private DNS Regions.
-- `private_connection_service_id` (String): The ID of your connection service.
- `name` (String) The private link name within the account. The name must start with a letter or underscore and can only contain letters, numbers, or underscores. Maximum size of name is 23 characters.
- `region` (String) Data processing location. This is where Fivetran will operate and run computation on data.
- `service` (String) Service type.

### Read-Only

- `cloud_provider` (String) The cloud provider name.
- `created_at` (String) The date and time the membership was created.
- `created_by` (String) The unique identifier for the User within the Fivetran system.
- `id` (String) The unique identifier for the private link within the Fivetran system.
- `state` (String) The state of the private link.
- `state_summary` (String) The state of the private link.
26 changes: 23 additions & 3 deletions fivetran/framework/core/model/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type ConnectorDatasourceModel struct {
ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
PrivateLinkId types.String `tfsdk:"private_link_id"`

Status types.Object `tfsdk:"status"`

Expand All @@ -61,6 +62,7 @@ func (d *ConnectorDatasourceModel) ReadFromResponse(resp connectors.DetailsWithC
d.ScheduleType = types.StringValue(resp.Data.ScheduleType)
d.Paused = types.BoolValue(*resp.Data.Paused)
d.PauseAfterTrial = types.BoolValue(*resp.Data.PauseAfterTrial)

if resp.Data.DailySyncTime != "" {
d.DailySyncTime = types.StringValue(resp.Data.DailySyncTime)
} else {
Expand Down Expand Up @@ -125,6 +127,7 @@ type ConnectorResourceModel struct {
ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
PrivateLinkId types.String `tfsdk:"private_link_id"`

Config types.Object `tfsdk:"config"`
Auth types.Object `tfsdk:"auth"`
Expand Down Expand Up @@ -204,6 +207,12 @@ func (d *ConnectorResourceModel) ReadFromContainer(c ConnectorModelContainer, fo

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

if c.PrivateLinkId != "" {
d.PrivateLinkId = types.StringValue(c.PrivateLinkId)
} else {
d.PrivateLinkId = types.StringNull()
}

if c.ProxyAgentId != "" {
d.ProxyAgentId = types.StringValue(c.ProxyAgentId)
} else {
Expand Down Expand Up @@ -237,7 +246,13 @@ func (d *ConnectorDatasourceModel) ReadFromContainer(c ConnectorModelContainer)
d.LocalProcessingAgentId = types.StringNull()
}

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

if c.PrivateLinkId != "" {
d.PrivateLinkId = types.StringValue(c.PrivateLinkId)
} else {
d.PrivateLinkId = types.StringNull()
}

if c.ProxyAgentId != "" {
d.ProxyAgentId = types.StringValue(c.ProxyAgentId)
Expand Down Expand Up @@ -270,6 +285,7 @@ type ConnectorModelContainer struct {
ProxyAgentId string
NetworkingMethod string
LocalProcessingAgentId string
PrivateLinkId string

Config map[string]interface{}

Expand All @@ -296,8 +312,12 @@ func (c *ConnectorModelContainer) ReadFromResponseData(data connectors.DetailsRe
c.NetworkingMethod = data.NetworkingMethod
}

if data.LocalProcessingAgentId != "" {
c.LocalProcessingAgentId = data.LocalProcessingAgentId
if data.HybridDeploymentAgentId != "" {
c.LocalProcessingAgentId = data.HybridDeploymentAgentId
}

if data.PrivateLinkId != "" {
c.PrivateLinkId = data.PrivateLinkId
}
}

Expand Down
4 changes: 3 additions & 1 deletion fivetran/framework/core/model/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type destinationModel interface {
SetDaylightSavingTimeEnabled(bool)
SetLocalProcessingAgentId(string)
SetNetworkingMethod(string)
SetPrivateLinkId(string)
SetConfig(map[string]interface{})
}

Expand All @@ -25,7 +26,8 @@ func readFromResponse(d destinationModel, resp destinations.DestinationDetailsBa
d.SetSetupStatus(resp.SetupStatus)
d.SetTimeZonOffset(resp.TimeZoneOffset)
d.SetDaylightSavingTimeEnabled(resp.DaylightSavingTimeEnabled)
d.SetLocalProcessingAgentId(resp.LocalProcessingAgentId)
d.SetLocalProcessingAgentId(resp.HybridDeploymentAgentId)
d.SetNetworkingMethod(resp.NetworkingMethod)
d.SetPrivateLinkId(resp.PrivateLinkId)
d.SetConfig(config)
}
8 changes: 8 additions & 0 deletions fivetran/framework/core/model/destination_datasource_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type DestinationDatasourceModel struct {
DaylightSavingTimeEnabled types.Bool `tfsdk:"daylight_saving_time_enabled"`
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
PrivateLinkId types.String `tfsdk:"private_link_id"`
Config types.Object `tfsdk:"config"`
}

Expand All @@ -43,6 +44,13 @@ func (d *DestinationDatasourceModel) SetSetupStatus(value string) {
func (d *DestinationDatasourceModel) SetDaylightSavingTimeEnabled(value bool) {
d.DaylightSavingTimeEnabled = types.BoolValue(value)
}
func (d *DestinationDatasourceModel) SetPrivateLinkId(value string) {
if value != "" {
d.PrivateLinkId = types.StringValue(value)
} else {
d.PrivateLinkId = types.StringNull()
}
}
func (d *DestinationDatasourceModel) SetLocalProcessingAgentId(value string) {
if value != "" {
d.LocalProcessingAgentId = types.StringValue(value)
Expand Down
8 changes: 8 additions & 0 deletions fivetran/framework/core/model/destination_resource_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type DestinationResourceModel struct {
Timeouts timeouts.Value `tfsdk:"timeouts"`
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
NetworkingMethod types.String `tfsdk:"networking_method"`
PrivateLinkId types.String `tfsdk:"private_link_id"`

RunSetupTests types.Bool `tfsdk:"run_setup_tests"`
TrustCertificates types.Bool `tfsdk:"trust_certificates"`
Expand Down Expand Up @@ -61,6 +62,13 @@ func (d *DestinationResourceModel) SetNetworkingMethod(value string) {
d.NetworkingMethod = types.StringValue(value)
}
}
func (d *DestinationResourceModel) SetPrivateLinkId(value string) {
if value != "" {
d.PrivateLinkId = types.StringValue(value)
} else {
d.PrivateLinkId = types.StringNull()
}
}
func (d *DestinationResourceModel) SetConfig(value map[string]interface{}) {
if d.Service.IsNull() || d.Service.IsUnknown() {
panic("Service type is null. Can't handle config without service type.")
Expand Down
8 changes: 4 additions & 4 deletions fivetran/framework/core/model/local_processing_agent.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package model

import (
"github.com/fivetran/go-fivetran/local_processing_agent"
localprocessingagent "github.com/fivetran/go-fivetran/hybrid_deployment_agent"
)

type localProcessingAgentModel interface {
Expand All @@ -12,18 +12,18 @@ type localProcessingAgentModel interface {
SetConfigJson(string)
SetAuthJson(string)
SetDockerComposeYaml(string)
SetUsage([]localprocessingagent.LocalProcessingAgentUsageDetails)
SetUsage([]localprocessingagent.HybridDeploymentAgentUsageDetails)
}

func readLocalProcessingAgentFromResponse(d localProcessingAgentModel, resp localprocessingagent.LocalProcessingAgentDetailsResponse) {
func readLocalProcessingAgentFromResponse(d localProcessingAgentModel, resp localprocessingagent.HybridDeploymentAgentDetailsResponse) {
d.SetId(resp.Data.Id)
d.SetDisplayName(resp.Data.DisplayName)
d.SetGroupId(resp.Data.GroupId)
d.SetRegisteredAt(resp.Data.RegisteredAt)
d.SetUsage(resp.Data.Usage)
}

func readLocalProcessingAgentFromCreateResponse(d localProcessingAgentModel, resp localprocessingagent.LocalProcessingAgentCreateResponse) {
func readLocalProcessingAgentFromCreateResponse(d localProcessingAgentModel, resp localprocessingagent.HybridDeploymentAgentCreateResponse) {
d.SetId(resp.Data.Id)
d.SetDisplayName(resp.Data.DisplayName)
d.SetGroupId(resp.Data.GroupId)
Expand Down
Loading
Loading