Aws_dms_endpoint for documentdb errors when used with secrets manager

End point is getting created only when the credentials are hardcoded as in the following resource (commented out lines). Its failing when we try to point it to secrets manager.

resource “aws_dms_endpoint” “target_endpoint_docdb” {

endpoint_id = “${var.name}-dms-target-aws-docdb-endpoint”

endpoint_type = “target”

engine_name = “docdb”

kms_key_arn = var.kms_key_arn

certificate_arn = aws_dms_certificate.cacerts.certificate_arn

database_name = “”

secrets_manager_arn = var.dms_aws_secrets_manager_arn_for_docdb

secrets_manager_access_role_arn = var.secrets_manager_access_role_arn

// password = “testpassword”

// port = 27017

// username = “master_user”

// server_name = “xx-ddd-test1-j98-docdb-primary-cluster.cluster-c4y4zpqku36y.us-east-1.docdb.amazonaws.com

}

I get the following message when I dont enter the port number and use only the secrets manager.

Error: updating DMS Endpoint (sf-dex-test1-use1-j99-env1-dms-target-aws-docdb-endpoint): InvalidParameterValueException: The parameter Port must be between 1 and 65535.

1907│ status code: 400, request id: 7d126b68-0836-475e-b5aa-13075ef34a4c

1908

1909│ with module.dms[“env1”].aws_dms_endpoint.target_endpoint_docdb,

1910│ on modules/dms/replication_docdb.tf line 10, in resource “aws_dms_endpoint” “target_endpoint_docdb”:

1911│ 10: resource “aws_dms_endpoint” “target_endpoint_docdb” {

I am being asked to enter the port number . And when I enter the port number 27017 along with the secrets manager, I get the following message.

Error: Conflicting configuration arguments

554

555│ with module.dms[“env1”].aws_dms_endpoint.target_endpoint_docdb,

556│ on modules/dms/replication_docdb.tf line 17, in resource “aws_dms_endpoint” “target_endpoint_docdb”:

557│ 17: port = 27017

558

559│ “port”: conflicts with secrets_manager_access_role_arn

560

561

562│ Error: Conflicting configuration arguments

563

564│ with module.dms[“env1”].aws_dms_endpoint.target_endpoint_docdb,

565│ on modules/dms/replication_docdb.tf line 19, in resource “aws_dms_endpoint” “target_endpoint_docdb”:

566│ 19: secrets_manager_arn = var.dms_aws_secrets_manager_arn_for_docdb

567

568│ “secrets_manager_arn”: conflicts with port

569

570

571│ Error: Conflicting configuration arguments

572

573│ with module.dms[“env1”].aws_dms_endpoint.target_endpoint_docdb,

574│ on modules/dms/replication_docdb.tf line 20, in resource “aws_dms_endpoint” “target_endpoint_docdb”:

575│ 20: secrets_manager_access_role_arn = var.secrets_manager_access_role_arn

576

577│ “secrets_manager_access_role_arn”: conflicts with port