fix(rds-postgres-server): grant KMS permissions for storage encryption CMK - #10
Merged
Merged
Conversation
added 5 commits
August 24, 2026 12:32
…e encryption rds-postgres-server/deployment always creates its own customer-managed KMS key for RDS storage encryption (required for AVD-AWS-0079 compliance, not optional), but specs/requirements/aws granted no kms:* actions at all, causing CreateKey/TagResource to fail with AccessDenied at apply time. Scope the new policy by the "managed-by=nullplatform" tag the deployment module already applies to the key, rather than "Resource": "*", so the role can only create/manage CMKs it tagged itself and can never touch any other KMS key in the account.
Live test surfaced a second missing permission after the previous kms:CreateKey/TagResource fix: the AWS provider reads the key policy back right after creating aws_kms_key.rds, which needs kms:GetKeyPolicy. Add it to the same tag-scoped ManageOwnCMK statement.
Live test surfaced a third missing permission: kms:CreateAlias authorizes against BOTH the alias ARN and the target key ARN as separate resource checks. The previous fix only covered the alias-ARN side (ManageOwnAlias); add the same three actions to the tag-scoped ManageOwnCMK statement so the key-side check passes too.
Live test surfaced a fourth missing permission: KMS has no DescribeAlias API, so the AWS provider reads aws_kms_alias back via ListAliases, which only supports "Resource": "*" (it enumerates every alias in the account/region, with no per-item ARN or tag condition available). Read-only: exposes alias names, not key material or policies.
…licy Keep the section header/one-liner pattern the rest of the file already uses; the detailed rationale lives in the PR description instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rds-postgres-server/deploymentalways creates its own customer-managed KMS key for RDS storage encryption (required for AVD-AWS-0079 compliance, not optional), butspecs/requirements/awsgranted nokms:*actions at all —create-rds-postgresql-serverfailed at apply time withAccessDeniedonkms:CreateKey.rds-postgres-serverpermissions role, gated on themanaged-by=nullplatformtag the deployment module already applies to the key it creates — not"Resource": "*"— so the role can create/manage only the CMKs it tags itself and can never touch, disable, or schedule deletion of any other KMS key in the account.rds_kms_policy_arnoutput, matching the existingrds_policy_arn/rds_sg_policy_arn/rds_secretsmanager_policy_arnoutputs.Why each permission is here (found via live testing against a real account, iterating on each AccessDenied)
kms:CreateKey/kms:TagResource— create the CMK and tag it.kms:GetKeyPolicy— the AWS provider reads the key policy back right after creatingaws_kms_key.rds.kms:CreateAlias/kms:DeleteAlias/kms:UpdateAliason both the tag-scoped key statement and a separate alias-ARN-scoped statement — these actions authorize against the alias ARN and the target key ARN as two independent resource checks.kms:ListAliases— KMS has no DescribeAlias API; the provider reads an alias back via ListAliases, which only supports "Resource": "*" (no per-item ARN/tag condition exists for this action). Read-only, exposes alias names only.kms:CreateGrant/kms:ListGrants/kms:RevokeGrant,kms:EnableKeyRotation/kms:GetKeyRotationStatus,kms:ScheduleKeyDeletion/kms:CancelKeyDeletion,kms:ListResourceTags,kms:DescribeKey— standard lifecycle management of the CMK the role itself created.Test plan