Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Cannot deploy more than one DMS aws_dms_replication_config due to duplicate service-linked role name #37434

Open
dom0do opened this issue May 10, 2024 · 1 comment
Labels
bug Addresses a defect in current functionality. service/dms Issues and PRs that pertain to the dms service.

Comments

@dom0do
Copy link

dom0do commented May 10, 2024

Terraform Core Version

1.4.6

AWS Provider Version

5.49.0

Affected Resource(s)

aws_dms_replication_config

Expected Behavior

Create multiple replication configs

Actual Behavior

The first replication is created and programmatically in the process spawns a service-linked IAM role apparently called "AWSServiceRoleForDMSServerless". Subsequent deploying configs try to do the exact same thing, spawning a role named "AWSServiceRoleForDMSServerless" which fails because the role with that name already exists. This means only the first replication config is provisioned and all others fail.

Given that the module does not support custom roles or role suffixes, I cannot see any workaround for this behavior.

Relevant Error/Panic Output Snippet

Error: creating DMS Replication Config (dev-babel-cdc-lo-batch): InvalidParameterValueException: Caught exception while trying to create the service-linked IAM role for DMS Serverless. Please ensure the account user has permission to create service-linked roles. Please follow the steps for using SLR here: https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html


"errorCode": "InvalidInputException",
"errorMessage": "Service role name AWSServiceRoleForDMSServerless has been taken in this account, please try a different suffix."

Terraform Configuration Files

resource "aws_dms_replication_config" "dev-tsc-batch" {
  count = (local.separate_validation == true) ? 2 : 1

  replication_config_identifier = lower((count.index == 0) ?
    "${local.task_id_serverless}-cdc-lo-batch" :
  "${local.task_id_serverless}-cdc-val-batch")

  resource_identifier = lower((count.index == 0) ?
    "${local.task_id_serverless}-cdc-lo-batch" :
  "${local.task_id_serverless}-cdc-val-batch")

  tags = merge(local.default_tags, (count.index == 0) ?
    { Name = "${local.task_id_serverless}-cdc-lo-batch" } :
  { Name = "${local.task_id_serverless}-cdc-val-batch" })

  source_endpoint_arn = aws_dms_endpoint.dev-tsc-source.endpoint_arn
  target_endpoint_arn = aws_dms_endpoint.dev-tsc-target.endpoint_arn

  compute_config {
    replication_subnet_group_id  = aws_dms_replication_subnet_group.dev-primary-private.replication_subnet_group_id
    min_capacity_units           = "2"
    max_capacity_units           = "128"
    preferred_maintenance_window = "sun:03:00-sun:04:00"
    vpc_security_group_ids       = [data.aws_security_group.default.id]
  }

  replication_type = lower((count.index == 0) ?
  "full-load-and-cdc" : "cdc")

  table_mappings = file((count.index == 0) ?
    "${local.table_mapping_cdc_batch}_load.json" :
  "${local.table_mapping_cdc_batch}_validate.json")

  replication_settings = templatefile("${path.module}/dms_settings.json.tpl", (count.index == 0) ?
    merge(local.task_settings_base, local.task_settings_serverless_cdc, local.task_settings_cdc_batch) :
  merge(local.task_settings_base, local.task_settings_validationonly, local.task_settings_serverless_cdc, local.task_settings_cdc_batch))
}

Steps to Reproduce

Try to provision multiple replication configs. Watch them fail with the service-linked role error. Confirm reason for SLR failure in CloudTrail.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

DMS docs

Would you like to implement a fix?

None

@dom0do dom0do added the bug Addresses a defect in current functionality. label May 10, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/dms Issues and PRs that pertain to the dms service. label May 10, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label May 10, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/dms Issues and PRs that pertain to the dms service.
Projects
None yet
Development

No branches or pull requests

2 participants