Skip to content
Merged
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ No modules.
| [aws_iam_policy_document.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [aws_service_principal.rds](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/service_principal) | data source |

## Inputs

Expand Down
7 changes: 6 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ locals {

data "aws_region" "current" {}
data "aws_partition" "current" {}
data "aws_service_principal" "rds" {
count = var.create && var.create_iam_role ? 1 : 0

service_name = "rds"
region = data.aws_region.current.name
}
################################################################################
# RDS Proxy
################################################################################
Expand Down Expand Up @@ -111,7 +116,7 @@ data "aws_iam_policy_document" "assume_role" {

principals {
type = "Service"
identifiers = ["rds.${data.aws_partition.current.dns_suffix}"]
identifiers = [data.aws_service_principal.rds[0].name]
}
}
}
Expand Down