Skip to content

Commit

Permalink
feat: DMS Endpoint postgres_settings (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
magreenbaum committed Dec 22, 2023
1 parent 615dc66 commit 9dd4bf1
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.31 |
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.31 |
| <a name="provider_time"></a> [time](#provider\_time) | >= 0.9 |

## Modules
Expand Down Expand Up @@ -385,6 +385,7 @@ No modules.
| <a name="input_repl_instance_id"></a> [repl\_instance\_id](#input\_repl\_instance\_id) | The replication instance identifier. This parameter is stored as a lowercase string | `string` | `null` | no |
| <a name="input_repl_instance_kms_key_arn"></a> [repl\_instance\_kms\_key\_arn](#input\_repl\_instance\_kms\_key\_arn) | The Amazon Resource Name (ARN) for the KMS key that will be used to encrypt the connection parameters | `string` | `null` | no |
| <a name="input_repl_instance_multi_az"></a> [repl\_instance\_multi\_az](#input\_repl\_instance\_multi\_az) | Specifies if the replication instance is a multi-az deployment. You cannot set the `availability_zone` parameter if the `multi_az` parameter is set to `true` | `bool` | `null` | no |
| <a name="input_repl_instance_network_type"></a> [repl\_instance\_network\_type](#input\_repl\_instance\_network\_type) | The type of IP address protocol used by a replication instance. Valid values: IPV4, DUAL | `string` | `null` | no |
| <a name="input_repl_instance_preferred_maintenance_window"></a> [repl\_instance\_preferred\_maintenance\_window](#input\_repl\_instance\_preferred\_maintenance\_window) | The weekly time range during which system maintenance can occur, in Universal Coordinated Time (UTC) | `string` | `null` | no |
| <a name="input_repl_instance_publicly_accessible"></a> [repl\_instance\_publicly\_accessible](#input\_repl\_instance\_publicly\_accessible) | Specifies the accessibility options for the replication instance | `bool` | `null` | no |
| <a name="input_repl_instance_subnet_group_id"></a> [repl\_instance\_subnet\_group\_id](#input\_repl\_instance\_subnet\_group\_id) | An existing subnet group to associate with the replication instance | `string` | `null` | no |
Expand Down
4 changes: 2 additions & 2 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ Note that this example may create resources which will incur monetary charges on
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.31 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.31 |

## Modules

Expand Down
6 changes: 6 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ module "dms_aurora_postgresql_aurora_mysql" {
extra_connection_attributes = "heartbeatFrequency=1;secretsManagerEndpointOverride=${module.vpc_endpoints.endpoints["secretsmanager"]["dns_entry"][0]["dns_name"]}"
secrets_manager_arn = module.secrets_manager_postgresql.secret_arn

postgres_settings = {
capture_ddls = false
heartbeat_enable = true
heartbeat_frequency = 1
}

tags = { EndpointType = "postgresql-source" }
}

Expand Down
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.0"
version = ">= 5.31"
}
random = {
source = "hashicorp/random"
Expand Down
31 changes: 29 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ resource "aws_dms_replication_instance" "this" {
engine_version = var.repl_instance_engine_version
kms_key_arn = var.repl_instance_kms_key_arn
multi_az = var.repl_instance_multi_az
network_type = var.repl_instance_network_type
preferred_maintenance_window = var.repl_instance_preferred_maintenance_window
publicly_accessible = var.repl_instance_publicly_accessible
replication_instance_class = var.repl_instance_class
Expand Down Expand Up @@ -186,6 +187,7 @@ resource "aws_dms_endpoint" "this" {
error_retry_duration = try(elasticsearch_settings.value.error_retry_duration, null)
full_load_error_percentage = try(elasticsearch_settings.value.full_load_error_percentage, null)
service_access_role_arn = lookup(elasticsearch_settings.value, "service_access_role_arn", aws_iam_role.access[0].arn)
use_new_mapping_type = try(elasticsearch_settings.value.use_new_mapping_type, null)
}
}

Expand Down Expand Up @@ -253,8 +255,32 @@ resource "aws_dms_endpoint" "this" {
}
}

password = lookup(each.value, "password", null)
port = try(each.value.port, null)
password = lookup(each.value, "password", null)
pause_replication_tasks = try(each.value.pause_replication_tasks, null)
port = try(each.value.port, null)

# https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Source.PostgreSQL.html
dynamic "postgres_settings" {
for_each = length(lookup(each.value, "postgres_settings", [])) > 0 ? [each.value.postgres_settings] : []
content {
after_connect_script = try(postgres_settings.value.after_connect_script, null)
babelfish_database_name = try(postgres_settings.value.babelfish_database_name, null)
capture_ddls = try(postgres_settings.value.capture_ddls, null)
database_mode = try(postgres_settings.value.database_mode, null)
ddl_artifacts_schema = try(postgres_settings.value.ddl_artifacts_schema, null)
execute_timeout = try(postgres_settings.value.execute_timeout, null)
fail_tasks_on_lob_truncation = try(postgres_settings.value.fail_tasks_on_lob_truncation, null)
heartbeat_enable = try(postgres_settings.value.heartbeat_enable, null)
heartbeat_frequency = try(postgres_settings.value.heartbeat_frequency, null)
heartbeat_schema = try(postgres_settings.value.heartbeat_schema, null)
map_boolean_as_boolean = try(postgres_settings.value.map_boolean_as_boolean, null)
map_jsonb_as_clob = try(postgres_settings.value.map_jsonb_as_clob, null)
map_long_varchar_as = try(postgres_settings.value.map_long_varchar_as, null)
max_file_size = try(postgres_settings.value.max_file_size, null)
plugin_name = try(postgres_settings.value.plugin_name, null)
slot_name = try(postgres_settings.value.slot_name, null)
}
}

dynamic "redis_settings" {
for_each = length(lookup(each.value, "redis_settings", [])) > 0 ? [each.value.redis_settings] : []
Expand Down Expand Up @@ -335,6 +361,7 @@ resource "aws_dms_s3_endpoint" "this" {
encryption_mode = try(each.value.encryption_mode, null)
expected_bucket_owner = try(each.value.expected_bucket_owner, null)
external_table_definition = try(each.value.external_table_definition, null)
glue_catalog_generation = try(each.value.glue_catalog_generation, null)
ignore_header_rows = try(each.value.ignore_header_rows, null)
include_op_for_full_load = try(each.value.include_op_for_full_load, null)
max_file_size = try(each.value.max_file_size, null)
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ variable "repl_instance_multi_az" {
default = null
}

variable "repl_instance_network_type" {
description = "The type of IP address protocol used by a replication instance. Valid values: IPV4, DUAL"
type = string
default = null
}

variable "repl_instance_preferred_maintenance_window" {
description = "The weekly time range during which system maintenance can occur, in Universal Coordinated Time (UTC)"
type = string
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.0"
version = ">= 5.31"
}
time = {
source = "hashicorp/time"
Expand Down

0 comments on commit 9dd4bf1

Please sign in to comment.