terraform-aws-rds icon indicating copy to clipboard operation
terraform-aws-rds copied to clipboard

Add support for RDS DB Instance role associations

Open adamantike opened this issue 3 years ago • 2 comments

Describe the Feature

Allow the module to internally configure aws_db_instance_role_association resources, to centralize more of the RDS configuration in this single module.

Describe Ideal Solution

Example code snippet, using for_each to have the TF state being indexed by the feature name.

variable "role_associations" {
  type        = map(string)
  description = "Map of role associations for the DB Instance. Key is the name of the feature for association, and value is the IAM Role ARN to associate. (e.g. { s3Import: \"arn:aws:iam::1234567890:role/rds-s3-import-role\" })"
  default     = {}
}

resource "aws_db_instance_role_association" "default" {
  for_each = module.this.enabled ? var.role_associations : {}

  db_instance_identifier = join("", aws_db_instance.default.*.id)
  feature_name           = each.key
  role_arn               = each.value
}

Alternatives Considered

Current alternative is to add these role associations using a separate resource block.

adamantike avatar Dec 23 '21 01:12 adamantike

Hi @adamantike, thanks for suggesting this.

I am working on this feature right now in #132.

korenyoni avatar Dec 26 '21 16:12 korenyoni

That's great, thank you for tackling it!

adamantike avatar Dec 27 '21 23:12 adamantike