-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INF-5307] - Add the Postgres Outbox Ably Ingress Rule
This adds the new Ably Ingress rule for Postgres Outbox. Documentation on this rule can be found at https://ably.com/docs/livesync/postgres
- Loading branch information
1 parent
8002ba6
commit 28cafe5
Showing
10 changed files
with
387 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "ably_ingress_rule_postgres_outbox Resource - terraform-provider-ably" | ||
subcategory: "" | ||
description: |- | ||
The ably_ingress_rule_postgres_outbox resource Use the Postgres database connector to distribute changes from your Postgres database to end users at scale. It enables you to distribute records using the outbox pattern to large numbers of subscribing clients, in realtime, as the changes occur. | ||
--- | ||
|
||
# ably_ingress_rule_postgres_outbox (Resource) | ||
|
||
The `ably_ingress_rule_postgres_outbox` resource Use the Postgres database connector to distribute changes from your Postgres database to end users at scale. It enables you to distribute records using the outbox pattern to large numbers of subscribing clients, in realtime, as the changes occur. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `app_id` (String) The Ably application ID. | ||
- `target` (Attributes) object (rule_source) (see [below for nested schema](#nestedatt--target)) | ||
|
||
### Optional | ||
|
||
- `status` (String) The status of the rule. Rules can be enabled or disabled. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The rule ID. | ||
|
||
<a id="nestedatt--target"></a> | ||
### Nested Schema for `target` | ||
|
||
Required: | ||
|
||
- `nodes_table_name` (String) Name for the nodes table. | ||
- `nodes_table_schema` (String) Schema for the nodes table in your database to allow for operation as a cluster to provide fault tolerance. | ||
- `outbox_table_name` (String) Name for the outbox table. | ||
- `outbox_table_schema` (String) Schema for the outbox table in your database which allows for the reliable publication of an ordered sequence of change event messages over Ably. | ||
- `primary_site` (String) The primary data center in which to run the integration rule. | ||
- `ssl_mode` (String) + ssl_mode (String) Determines the level of protection provided by the SSL connection. Options are: | ||
- prefer: Attempt SSL but allow non-SSL. | ||
- require: Always use SSL but don't verify certificates. | ||
- verify-ca: Verify server certificate is signed by a trusted CA. | ||
- verify-full: Verify server certificate and hostname. | ||
|
||
Default: prefer. | ||
- `url` (String) The URL for your Postgres database, for example postgres://user:password@example.com:5432/your-database-name. The associated user must have the correct privileges | ||
|
||
Optional: | ||
|
||
- `ssl_root_cert` (String) Optional. Specifies the SSL certificate authority (CA) certificates. Required if SSL mode is verify-ca or verify-full. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
resource "ably_ingress_rule_postgres_outbox" "rule0" { | ||
app_id = ably_app.app0.id | ||
status = "enabled" | ||
target = { | ||
url = "postgres://${var.postgres_user}:${var.postgres_password}@${var.postgres_host}:5432/${var.postgres_db}" | ||
outbox_table_schema = "public" | ||
outbox_table_name = "outbox" | ||
nodes_table_schema = "public" | ||
nodes_table_name = "nodes" | ||
ssl_mode = "prefer" | ||
ssl_root_cert = "-----BEGIN CERTIFICATE----- MIIFiTCCA3GgAwIBAgIUYO1Lomxzj7VRawWwEFiQht9OLpUwDQYJKoZIhvcNAQEL BQAwTDELMAkGA1UEBhMCVVMxETAPBgNVBAgMCE1pY2hpZ2FuMQ8wDQYDVQQHDAZX ...snip... TOfReTlUQzgpXRW5h3n2LVXbXQhPGcVitb88Cm2R8cxQwgB1VncM8yvmKhREo2tz 7Y+sUx6eIl4dlNl9kVrH1TD3EwwtGsjUNlFSZhg= -----END CERTIFICATE-----" | ||
primary_site = "us-east-1-A" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
variable "mongodb_user" { | ||
description = "MongoDB username" | ||
sensitive = true | ||
default = "test" | ||
} | ||
|
||
variable "mongodb_password" { | ||
description = "MongoDB password" | ||
sensitive = true | ||
default = "test" | ||
} | ||
|
||
variable "mongodb_host" { | ||
description = "MongoDB host" | ||
default = "test" | ||
} | ||
|
||
variable "postgres_user" { | ||
description = "PostgreSQL username" | ||
sensitive = true | ||
default = "test" | ||
} | ||
|
||
variable "postgres_password" { | ||
description = "PostgreSQL password" | ||
sensitive = true | ||
default = "test" | ||
} | ||
|
||
variable "postgres_host" { | ||
description = "PostgreSQL host" | ||
default = "test" | ||
} | ||
|
||
variable "postgres_db" { | ||
description = "PostgreSQL database name" | ||
default = "test" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
internal/provider/resource_ably_ingress_rule_postgres_outbox.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package ably_control | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/diag" | ||
tfsdk_resource "github.com/hashicorp/terraform-plugin-framework/resource" | ||
"github.com/hashicorp/terraform-plugin-framework/tfsdk" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
) | ||
|
||
type resourceIngressRulePostgresOutbox struct { | ||
p *provider | ||
} | ||
|
||
// Get Rule Resource schema | ||
func (r resourceIngressRulePostgresOutbox) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { | ||
return GetIngressRuleSchema( | ||
map[string]tfsdk.Attribute{ | ||
"url": { | ||
Type: types.StringType, | ||
Required: true, | ||
Description: "The URL for your Postgres database, for example postgres://user:[email protected]:5432/your-database-name. The associated user must have the correct privileges", | ||
}, | ||
"outbox_table_schema": { | ||
Type: types.StringType, | ||
Required: true, | ||
Description: "Schema for the outbox table in your database which allows for the reliable publication of an ordered sequence of change event messages over Ably.", | ||
}, | ||
"outbox_table_name": { | ||
Type: types.StringType, | ||
Required: true, | ||
Description: "Name for the outbox table.", | ||
}, | ||
"nodes_table_schema": { | ||
Type: types.StringType, | ||
Required: true, | ||
Description: "Schema for the nodes table in your database to allow for operation as a cluster to provide fault tolerance.", | ||
}, | ||
"nodes_table_name": { | ||
Type: types.StringType, | ||
Required: true, | ||
Description: "Name for the nodes table.", | ||
}, | ||
"ssl_mode": { | ||
Type: types.StringType, | ||
Required: true, | ||
Description: `+ ssl_mode (String) Determines the level of protection provided by the SSL connection. Options are: | ||
- prefer: Attempt SSL but allow non-SSL. | ||
- require: Always use SSL but don't verify certificates. | ||
- verify-ca: Verify server certificate is signed by a trusted CA. | ||
- verify-full: Verify server certificate and hostname. | ||
Default: prefer.`, | ||
}, | ||
"ssl_root_cert": { | ||
Type: types.StringType, | ||
Optional: true, | ||
Description: "Optional. Specifies the SSL certificate authority (CA) certificates. Required if SSL mode is verify-ca or verify-full.", | ||
}, | ||
"primary_site": { | ||
Type: types.StringType, | ||
Required: true, | ||
Description: " The primary data center in which to run the integration rule.", | ||
}, | ||
}, | ||
"The `ably_ingress_rule_postgres_outbox` resource Use the Postgres database connector to distribute changes from your Postgres database to end users at scale. It enables you to distribute records using the outbox pattern to large numbers of subscribing clients, in realtime, as the changes occur."), nil | ||
} | ||
|
||
func (r resourceIngressRulePostgresOutbox) Metadata(ctx context.Context, req tfsdk_resource.MetadataRequest, resp *tfsdk_resource.MetadataResponse) { | ||
resp.TypeName = "ably_ingress_rule_postgres_outbox" | ||
} | ||
|
||
func (r *resourceIngressRulePostgresOutbox) Provider() *provider { | ||
return r.p | ||
} | ||
|
||
func (r *resourceIngressRulePostgresOutbox) Name() string { | ||
return "PostgresOutbox" | ||
} | ||
|
||
// Create a new resource | ||
func (r resourceIngressRulePostgresOutbox) Create(ctx context.Context, req tfsdk_resource.CreateRequest, resp *tfsdk_resource.CreateResponse) { | ||
CreateIngressRule[AblyIngressRuleTargetPostgresOutbox](&r, ctx, req, resp) | ||
} | ||
|
||
// Read resource | ||
func (r resourceIngressRulePostgresOutbox) Read(ctx context.Context, req tfsdk_resource.ReadRequest, resp *tfsdk_resource.ReadResponse) { | ||
ReadIngressRule[AblyIngressRuleTargetPostgresOutbox](&r, ctx, req, resp) | ||
} | ||
|
||
// Update resource | ||
func (r resourceIngressRulePostgresOutbox) Update(ctx context.Context, req tfsdk_resource.UpdateRequest, resp *tfsdk_resource.UpdateResponse) { | ||
UpdateIngressRule[AblyIngressRuleTargetPostgresOutbox](&r, ctx, req, resp) | ||
} | ||
|
||
// Delete resource | ||
func (r resourceIngressRulePostgresOutbox) Delete(ctx context.Context, req tfsdk_resource.DeleteRequest, resp *tfsdk_resource.DeleteResponse) { | ||
DeleteIngressRule[AblyIngressRuleTargetPostgresOutbox](&r, ctx, req, resp) | ||
} | ||
|
||
// Import resource | ||
func (r resourceIngressRulePostgresOutbox) ImportState(ctx context.Context, req tfsdk_resource.ImportStateRequest, resp *tfsdk_resource.ImportStateResponse) { | ||
ImportResource(ctx, req, resp, "app_id", "id") | ||
} |
Oops, something went wrong.