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 connection_type: S3 #40

Merged
merged 29 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
23 changes: 22 additions & 1 deletion docs/resources/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ resource "trocco_connection" "snowflake" {

### Required

- `connection_type` (String) The type of the connection. It must be one of `bigquery`, `snowflake`, `gcs`, or `mysql`.
- `connection_type` (String) The type of the connection. It must be one of `bigquery`, `snowflake`, `gcs`, `mysql`, or `s3`.
- `name` (String) The name of the connection.

### Optional

- `application_name` (String) GCS: Application name.
- `auth_method` (String) Snowflake: The authentication method for the Snowflake user. It must be one of `key_pair` or `user_password`.
- `aws_assume_role` (Attributes) S3: AssumeRole configuration. (see [below for nested schema](#nestedatt--aws_assume_role))
- `aws_auth_type` (String) S3: The authentication type for the S3 connection. It must be one of `iam_user` or `assume_role`.
- `aws_iam_user` (Attributes) S3: IAM User configuration. (see [below for nested schema](#nestedatt--aws_iam_user))
- `description` (String) The description of the connection.
- `gateway` (Attributes) MySQL: Whether to connect via SSH (see [below for nested schema](#nestedatt--gateway))
- `host` (String) Snowflake: The host of a Snowflake account.
Expand All @@ -78,6 +81,24 @@ resource "trocco_connection" "snowflake" {

- `id` (Number) The ID of the connection.

<a id="nestedatt--aws_assume_role"></a>
### Nested Schema for `aws_assume_role`

Optional:

- `account_id` (String) S3: The account ID for the AssumeRole configuration.
- `role_name` (String) S3: The account role name for the AssumeRole configuration.


<a id="nestedatt--aws_iam_user"></a>
### Nested Schema for `aws_iam_user`

Optional:

- `access_key_id` (String) S3: The access key ID for the S3 connection.
- `secret_access_key` (String, Sensitive) S3: The secret access key for the S3 connection.


<a id="nestedatt--gateway"></a>
### Nested Schema for `gateway`

Expand Down
25 changes: 25 additions & 0 deletions examples/resources/trocco_connection/s3.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resource "trocco_connection" "s3" {
connection_type = "s3"

name = "S3 Example"
description = "This is a AWS S3 connection example"

aws_auth_type = "iam_user"
aws_iam_user = {
access_key_id = "YOUR_ACCESS_KEY_ID"
secret_access_key = "YOUR_SECRET_ACCESS_KEY"
}
}

resource "trocco_connection" "s3_with_assume_role" {
connection_type = "s3"

name = "S3 Example"
description = "This is a AWS S3 connection example"

aws_auth_type = "assume_role"
aws_assume_role = {
account_id = "123456789012"
role_name = "YOUR_ROLE_NAME"
}
}
21 changes: 21 additions & 0 deletions internal/client/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ type Connection struct {
GatewayPassword *string `json:"gateway_password"`
GatewayKey *string `json:"gateway_key"`
GatewayKeyPassphrase *string `json:"gateway_key_passphrase"`

// S3 Fields
AWSAuthType *string `json:"aws_auth_type,omitempty"`
AWSAccessKeyID *string `json:"aws_access_key_id,omitempty"`
AWSSecretAccessKey *string `json:"aws_secret_access_key,omitempty"`
AWSAssumeRoleAccountID *string `json:"aws_assume_role_account_id,omitempty"`
AWSAssumeRoleName *string `json:"aws_assume_role_name,omitempty"`
}

type GetConnectionsInput struct {
Expand Down Expand Up @@ -92,6 +99,13 @@ type CreateConnectionInput struct {
GatewayPassword *string `json:"gateway_password,omitempty"`
GatewayKey *string `json:"gateway_key,omitempty"`
GatewayKeyPassphrase *string `json:"gateway_key_passphrase,omitempty"`

// S3 Fields
AWSAuthType *string `json:"aws_auth_type,omitempty"`
AWSAccessKeyID *string `json:"aws_access_key_id,omitempty"`
AWSSecretAccessKey *string `json:"aws_secret_access_key,omitempty"`
AWSAssumeRoleAccountID *string `json:"aws_assume_role_account_id,omitempty"`
AWSAssumeRoleName *string `json:"aws_assume_role_name,omitempty"`
}

type UpdateConnectionInput struct {
Expand Down Expand Up @@ -129,6 +143,13 @@ type UpdateConnectionInput struct {
GatewayPassword *string `json:"gateway_password,omitempty"`
GatewayKey *string `json:"gateway_key,omitempty"`
GatewayKeyPassphrase *string `json:"gateway_key_passphrase,omitempty"`

// S3 Fields
AWSAuthType *string `json:"aws_auth_type,omitempty"`
AWSAccessKeyID *string `json:"aws_access_key_id,omitempty"`
AWSSecretAccessKey *string `json:"aws_secret_access_key,omitempty"`
AWSAssumeRoleAccountID *string `json:"aws_assume_role_account_id,omitempty"`
AWSAssumeRoleName *string `json:"aws_assume_role_name,omitempty"`
}

func (c *TroccoClient) GetConnections(connectionType string, in *GetConnectionsInput) (*ConnectionList, error) {
Expand Down
Loading