Skip to content

Commit f7a75ef

Browse files
milldraknysh
andauthored
Corrections to dms components (#658)
Co-authored-by: Andriy Knysh <[email protected]>
1 parent bd3f21b commit f7a75ef

File tree

7 files changed

+58
-22
lines changed

7 files changed

+58
-22
lines changed

modules/dms/endpoint/README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ components:
7474
7575
| Name | Version |
7676
|------|---------|
77-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2.0 |
77+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
7878
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.26.0 |
7979
8080
## Providers
8181
82-
No providers.
82+
| Name | Version |
83+
|------|---------|
84+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.26.0 |
8385
8486
## Modules
8587
@@ -91,7 +93,10 @@ No providers.
9193
9294
## Resources
9395
94-
No resources.
96+
| Name | Type |
97+
|------|------|
98+
| [aws_ssm_parameter.password](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
99+
| [aws_ssm_parameter.username](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
95100
96101
## Inputs
97102
@@ -123,7 +128,8 @@ No resources.
123128
| <a name="input_mongodb_settings"></a> [mongodb\_settings](#input\_mongodb\_settings) | Configuration block for MongoDB settings | `map(any)` | `null` | no |
124129
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
125130
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
126-
| <a name="input_password"></a> [password](#input\_password) | Password to be used to login to the endpoint database | `string` | `null` | no |
131+
| <a name="input_password"></a> [password](#input\_password) | Password to be used to login to the endpoint database | `string` | `""` | no |
132+
| <a name="input_password_path"></a> [password\_path](#input\_password\_path) | If set, the path in AWS SSM Parameter Store to fetch the password for the DMS admin user | `string` | `""` | no |
127133
| <a name="input_port"></a> [port](#input\_port) | Port used by the endpoint database | `number` | `null` | no |
128134
| <a name="input_redshift_settings"></a> [redshift\_settings](#input\_redshift\_settings) | Configuration block for Redshift settings | `map(any)` | `null` | no |
129135
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
@@ -137,7 +143,8 @@ No resources.
137143
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
138144
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
139145
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
140-
| <a name="input_username"></a> [username](#input\_username) | User name to be used to login to the endpoint database | `string` | `null` | no |
146+
| <a name="input_username"></a> [username](#input\_username) | User name to be used to login to the endpoint database | `string` | `""` | no |
147+
| <a name="input_username_path"></a> [username\_path](#input\_username\_path) | If set, the path in AWS SSM Parameter Store to fetch the username for the DMS admin user | `string` | `""` | no |
141148

142149
## Outputs
143150

modules/dms/endpoint/main.tf

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
locals {
2+
fetch_username = !(length(var.username) > 0) && (length(var.username_path) > 0) ? true : false
3+
fetch_password = !(length(var.password) > 0) && (length(var.password_path) > 0) ? true : false
4+
}
5+
6+
data "aws_ssm_parameter" "username" {
7+
count = local.fetch_username ? 1 : 0
8+
name = var.username_path
9+
}
10+
11+
data "aws_ssm_parameter" "password" {
12+
count = local.fetch_password ? 1 : 0
13+
name = var.password_path
14+
}
15+
116
module "dms_endpoint" {
217
source = "cloudposse/dms/aws//modules/dms-endpoint"
318
version = "0.1.1"
@@ -7,15 +22,15 @@ module "dms_endpoint" {
722
kms_key_arn = var.kms_key_arn
823
certificate_arn = var.certificate_arn
924
database_name = var.database_name
10-
password = var.password
1125
port = var.port
1226
extra_connection_attributes = var.extra_connection_attributes
1327
secrets_manager_access_role_arn = var.secrets_manager_access_role_arn
1428
secrets_manager_arn = var.secrets_manager_arn
1529
server_name = var.server_name
1630
service_access_role = var.service_access_role
1731
ssl_mode = var.ssl_mode
18-
username = var.username
32+
username = local.fetch_username ? data.aws_ssm_parameter.username[0].value : var.username
33+
password = local.fetch_password ? data.aws_ssm_parameter.password[0].value : var.password
1934
elasticsearch_settings = var.elasticsearch_settings
2035
kafka_settings = var.kafka_settings
2136
kinesis_settings = var.kinesis_settings

modules/dms/endpoint/variables.tf

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ variable "database_name" {
3434
variable "password" {
3535
type = string
3636
description = "Password to be used to login to the endpoint database"
37-
default = null
37+
default = ""
3838
}
3939

4040
variable "port" {
@@ -82,7 +82,7 @@ variable "ssl_mode" {
8282
variable "username" {
8383
type = string
8484
description = "User name to be used to login to the endpoint database"
85-
default = null
85+
default = ""
8686
}
8787

8888
variable "elasticsearch_settings" {
@@ -120,3 +120,16 @@ variable "s3_settings" {
120120
description = "Configuration block for S3 settings"
121121
default = null
122122
}
123+
124+
variable "username_path" {
125+
type = string
126+
description = "If set, the path in AWS SSM Parameter Store to fetch the username for the DMS admin user"
127+
default = ""
128+
}
129+
130+
variable "password_path" {
131+
type = string
132+
description = "If set, the path in AWS SSM Parameter Store to fetch the password for the DMS admin user"
133+
default = ""
134+
}
135+

modules/dms/endpoint/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 1.2.0"
2+
required_version = ">= 1.0"
33

44
required_providers {
55
aws = {

modules/dms/iam/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ components:
2929
| Name | Version |
3030
|------|---------|
3131
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
32-
| <a name="requirement_source"></a> [source](#requirement\_source) | hashicorp/aws |
33-
| <a name="requirement_version"></a> [version](#requirement\_version) | >= 4.26.0 |
32+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.26.0 |
3433
3534
## Providers
3635

modules/dms/iam/versions.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ terraform {
22
required_version = ">= 1.0"
33

44
required_providers {
5-
source = "hashicorp/aws"
6-
# Using the latest version of the provider since the earlier versions had many issues with DMS replication tasks.
7-
# In particular:
8-
# https://github.com/hashicorp/terraform-provider-aws/pull/24047
9-
# https://github.com/hashicorp/terraform-provider-aws/pull/23692
10-
# https://github.com/hashicorp/terraform-provider-aws/pull/13476
11-
version = ">= 4.26.0"
5+
aws = {
6+
source = "hashicorp/aws"
7+
# Using the latest version of the provider since the earlier versions had many issues with DMS replication tasks.
8+
# In particular:
9+
# https://github.com/hashicorp/terraform-provider-aws/pull/24047
10+
# https://github.com/hashicorp/terraform-provider-aws/pull/23692
11+
# https://github.com/hashicorp/terraform-provider-aws/pull/13476
12+
version = ">= 4.26.0"
13+
}
1214
}
1315
}

modules/dms/replication-task/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module "dms_replication_task" {
22
source = "cloudposse/dms/aws//modules/dms-replication-task"
33
version = "0.1.1"
44

5-
replication_instance_arn = module.dms_replication_instance.outputs.replication_instance_arn
6-
source_endpoint_arn = module.dms_endpoint_source.outputs.endpoint_arn
7-
target_endpoint_arn = module.dms_endpoint_target.outputs.endpoint_arn
5+
replication_instance_arn = module.dms_replication_instance.outputs.dms_replication_instance_arn
6+
source_endpoint_arn = module.dms_endpoint_source.outputs.dms_endpoint_arn
7+
target_endpoint_arn = module.dms_endpoint_target.outputs.dms_endpoint_arn
88

99
start_replication_task = var.start_replication_task
1010
migration_type = var.migration_type

0 commit comments

Comments
 (0)