Skip to content

fix: add KMS IAM policy to the aurora-postgres-server permissions role - #6

Merged
timossileandro merged 1 commit into
mainfrom
feat/kms-iam-policies
Aug 24, 2026
Merged

fix: add KMS IAM policy to the aurora-postgres-server permissions role#6
timossileandro merged 1 commit into
mainfrom
feat/kms-iam-policies

Conversation

@timossileandro

Copy link
Copy Markdown
Contributor

What

Adds a <prefix>-rds-kms-policy IAM policy — and its role attachment — to the
aurora-postgres-server AssumeRole permissions role in
specs/requirements/aws/main.tf.

Why

0.0.2 moved Aurora storage encryption to a customer managed key
(5f71cc7, AVD-AWS-0079): deployment/main.tf now creates aws_kms_key.aurora +
aws_kms_alias.aurora and feeds the key ARN into aws_rds_cluster.main. The
permissions role that the agent assumes was never updated to match, so the KMS
calls in the deployment plan are denied — the service can't complete its first
apply, and a destroy leaves the key and alias behind.

What the policy grants

  • KmsCreateAndListkms:CreateKey, TagResource, ListKeys,
    ListAliases. Resource * because there is no key ARN to scope to before
    CreateKey returns.
  • KmsManageKey — describe / key policy / rotation / tags / lifecycle
    (including ScheduleKeyDeletion and CancelKeyDeletion), scoped to keys in
    the current account via data.aws_caller_identity.current.account_id.
  • KmsCreateGrantForRdsCreateGrant / ListGrants / RevokeGrant,
    gated on kms:GrantIsForAWSResource = true. RDS creates a grant on the CMK
    when it attaches the key to the cluster; without this, cluster creation fails
    with a KMS access error even though the key already exists.
  • KmsManageAliasCreateAlias / UpdateAlias / DeleteAlias on
    alias/nullplatform-aurora-* (the alias pattern deployment/main.tf uses)
    plus the key resource, since the alias APIs authorize against both the alias
    and its target key.

Every resource is behind count = local.iam_create ? 1 : 0, in line with the
other policies in the module, so accounts that bring their own role are
unaffected.

Scope and impact

  • Single file touched: aurora-postgres-server/specs/requirements/aws/main.tf.
    No changes to deployment/, workflows, or specs; aurora-postgres-db is
    untouched.
  • Existing installations must re-apply specs/requirements/aws to pick up the
    new policy and attachment. The role name and trust policy are unchanged, so
    nothing needs to be re-registered on the nullplatform side
    (identity-access-control provider and selector stay the same).
  • No new Trivy suppressions: the wildcard-resource pattern already exists in the
    RDS, security group and Secrets Manager policies in this module.

Verification

  • tofu fmt -check and tofu validate in
    aurora-postgres-server/specs/requirements/aws.
  • tofu plan on a test account: the plan adds one aws_iam_policy and one
    aws_iam_role_policy_attachment, with no changes to the existing role or
    policies.
  • End to end: create an aurora-postgres-server service on an account whose
    role comes from this module and confirm the cluster comes up with the CMK,
    then delete it and confirm the key is scheduled for deletion and the alias is
    removed.

Release 0.0.2 moved Aurora storage encryption to a customer managed key
(5f71cc7, AVD-AWS-0079): deployment/main.tf creates aws_kms_key.aurora and
aws_kms_alias.aurora and feeds the key ARN into aws_rds_cluster.main. The
AssumeRole permissions role was never updated to match, so the agent's KMS
calls are denied: the service cannot finish its first apply, and a destroy
leaves the key and its alias behind.

Adds <prefix>-rds-kms-policy plus its role attachment, gated by the same
local.iam_create flag as the rest of the policies in the module:

- KmsCreateAndList: CreateKey, TagResource, ListKeys and ListAliases on "*",
  since there is no key ARN to scope to before CreateKey returns.
- KmsManageKey: describe, key policy, rotation, tags and lifecycle, scoped to
  keys in the current account.
- KmsCreateGrantForRds: CreateGrant, ListGrants and RevokeGrant gated on
  kms:GrantIsForAWSResource, which RDS requires to attach the key to the
  cluster.
- KmsManageAlias: alias create, update and delete on alias/nullplatform-aurora-*
  plus the target key, since the alias APIs authorize against both.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@sebastiancorrea81 sebastiancorrea81 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@timossileandro
timossileandro merged commit ecfb57f into main Aug 24, 2026
6 checks passed
@timossileandro
timossileandro deleted the feat/kms-iam-policies branch August 24, 2026 20:34
@timossileandro
timossileandro restored the feat/kms-iam-policies branch August 25, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants