Skip to content

Create DMS target endpoint via Terraform - Redshift Serverless

0

I'm unable to create a DMS target endpoint for a Redshift Serverless via Terraform (Both DMS and Redshift are in the same account and region).

resource "aws_dms_endpoint" "target" {
  endpoint_id   = "corail-cloud-target-redshift"
  endpoint_type = "target"
  engine_name   = "redshift"
  server_name   = aws_redshiftserverless_workgroup.default_workgroup.endpoint[0].address
  port          = 5439
  database_name = "corail_database"
  username      = aws_redshiftserverless_namespace.default_namespace.admin_username
  password      = aws_redshiftserverless_namespace.default_namespace.admin_user_password
}

It gives me a │ Error: creating DMS Endpoint (*********): operation error Database Migration Service: CreateEndpoint, https response error StatusCode: 400, RequestID: <id>, api error InvalidParameterValueException: Unable to extract cluster identifier and cluster region from the server name *****

However, if I do the same thing as Postgres engine, everything goes well

resource "aws_dms_endpoint" "target" {
  endpoint_id   = "corail-cloud-source-redshift"
  endpoint_type = "target"
  engine_name   = "postgres"
  server_name   = aws_redshiftserverless_workgroup.default_workgroup.endpoint[0].address
  port          = 5439
  database_name = "corail_database"
  username      = "corail_user"
  password      = "Corail_Password_0"
}

is this a bug in the Terraform provider? or am I doing something wrong?

1 Answer
0
Accepted Answer

The issue you're encountering is not a bug in the Terraform provider, but rather a misunderstanding of how to configure a DMS endpoint for Amazon Redshift Serverless. When creating a DMS target endpoint for Redshift Serverless, you need to use specific settings that differ from a standard Redshift cluster or a PostgreSQL database.

To create a DMS target endpoint for Redshift Serverless, you should make the following changes to your Terraform configuration:

  1. Change the engine_name to "redshift-serverless" instead of "redshift" or "postgres".

  2. In the server_name field, use the workgroup endpoint. This should be in the format: workgroup-name.account-number.aws-region.redshift-serverless.amazonaws.com.

  3. Add a redshift_settings block to specify additional Redshift Serverless-specific configurations.

Here's an updated version of your Terraform configuration that should work for creating a DMS target endpoint for Redshift Serverless:

resource "aws_dms_endpoint" "target" {
  endpoint_id   = "corail-cloud-target-redshift-serverless"
  endpoint_type = "target"
  engine_name   = "redshift-serverless"
  server_name   = aws_redshiftserverless_workgroup.default_workgroup.endpoint[0].address
  port          = 5439
  database_name = "corail_database"
  username      = aws_redshiftserverless_namespace.default_namespace.admin_username
  password      = aws_redshiftserverless_namespace.default_namespace.admin_user_password

  redshift_settings {
    server_name = aws_redshiftserverless_workgroup.default_workgroup.endpoint[0].address
  }
}

This configuration uses the correct engine name for Redshift Serverless and includes the necessary redshift_settings block. The server_name is specified both in the main resource block and in the redshift_settings block to ensure proper configuration.

By making these changes, you should be able to successfully create a DMS target endpoint for your Redshift Serverless instance using Terraform.
Sources
New features in AWS DMS 3.5.1 | AWS Database Blog
Using an Amazon Redshift database as a target for AWS Database Migration Service - AWS Database Migration Service
Connecting to Amazon Redshift Serverless - Amazon Redshift

answered 9 months ago
EXPERT
reviewed 9 months ago
  • Indeed, I just found that I had the wrong engine_name, thanks a lot!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.