I created an AWS RDS proxy with terraform:
resource "aws_iam_role" "my_role" {
name = "proxy"
path = "/service-role/"
assume_role_policy = <<-EOT
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "rds.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOT
}
resource "aws_iam_policy" "my_policy" {
name = "proxy-policy"
policy = <<-EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue"
],
"Resource": "${aws_secretsmanager_secret.my_secret.arn}"
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "my_policy" {
role = aws_iam_role.my_role.name
policy_arn = aws_iam_policy.my_policy.arn
}
resource "aws_db_proxy" "my_proxy" {
name = "my-proxy"
debug_logging = true
engine_family = "MYSQL"
idle_client_timeout = 900
require_tls = true
role_arn = aws_iam_role.my_role.arn
vpc_security_group_ids = ["sg-123"]
vpc_subnet_ids = ["subnet-123"]
auth {
auth_scheme = "SECRETS"
iam_auth = "DISABLED"
secret_arn = aws_secretsmanager_secret.my_secret.arn
}
}
resource "aws_db_proxy_default_target_group" "my_proxy" {
db_proxy_name = aws_db_proxy.my_proxy.name
}
resource "aws_db_proxy_target" "my_proxy" {
db_cluster_identifier = "my-cluster"
db_proxy_name = aws_db_proxy.my_proxy.name
target_group_name = aws_db_proxy_default_target_group.my_proxy.name
}
I can't connect to the generated endpoint though. When checking with aws rds describe-db-proxy-targets --db-proxy-name my-proxy --region us-west-2, i get this:
{
"Targets": [
{
"RdsResourceId": "my-cluster",
"Port": 3306,
"Type": "TRACKED_CLUSTER"
},
{
"Endpoint": "yyy.us-west-2.rds.amazonaws.com",
"TrackedClusterId": "my-cluster",
"RdsResourceId": "my-cluster-123",
"Port": 3306,
"Type": "RDS_INSTANCE",
"Role": "UNKNOWN",
"TargetHealth": {
"State": "UNAVAILABLE",
"Reason": "PENDING_PROXY_CAPACITY",
"Description": "DBProxy Target is waiting for proxy to scale to desired capacity"
}
}
]
}
When checking the Cloudwatch logs for /aws/rds/proxy/core-db, there is nothing. Is there anything else I can do to debug this? Any directions?