Skip to content

change from username to jbid for principalTag #11

Merged
merged 1 commit into from
Jul 8, 2026
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions policies/sc-dbuser/policy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ data "aws_iam_policy_document" "inline" {
# Can't embed dbuser here — PI scopes to the DB resource, not user — leave or separate
resources = [format("arn:%v:%v:*:*:%v", data.aws_arn.current.partition, "pi", "metrics/rds/*")]
}
# Deny rds-db:connect if the session tag UserName is not present (i.e. not authenticated via SSO or STS)
# Deny rds-db:connect if the session tag jbid is not present (i.e. not authenticated via SSO or STS)
statement {
sid = "DenyRDSConnectIfNoTag"
effect = "Deny"
actions = ["rds-db:connect"]
resources = ["*"]
condition {
test = "Null"
variable = "aws:PrincipalTag/UserName"
variable = "aws:PrincipalTag/jbid"
values = ["true"]
}
}
# Allow rds-db:connect if the session tag UserName matches the DB username in the resource ARN
# Allow rds-db:connect if the session tag jbid matches the DB jbid in the resource ARN
statement {
sid = "AllowRDSConnectSelf"
effect = "Allow"
actions = ["rds-db:connect"]
resources = [
# Scopes to only the DB username matching their session tag
format("arn:%v:%v:*:*:%v:*/$${aws:PrincipalTag/UserName}", data.aws_arn.current.partition, "rds-db", "dbuser")
# Scopes to only the DB jbid matching their session tag
format("arn:%v:%v:*:*:%v:*/$${aws:PrincipalTag/jbid}", data.aws_arn.current.partition, "rds-db", "dbuser")
]
}
}