-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add kms key arn input for customer-managed keys #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new variable, Changes
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Require terratestWonderful, this rule succeeded.This rule require terratest status
|
/terratest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/variables.tf (1)
50-54
: Add validation for KMS Key ARN format
To ensure users provide a valid KMS key ARN (or leave it null to let the module generate one), consider adding avalidation
block that checks the ARN pattern. This will catch typos early and surface a clear error message.variable "kms_key_arn" { type = string description = "The ARN for the KMS encryption key." default = null validation { condition = var.kms_key_arn == null || can(regex("^arn:aws:kms:[^:]+:[0-9]{12}:key/[A-Za-z0-9\\-_/]+$", var.kms_key_arn)) error_message = "The value for kms_key_arn must be a valid AWS KMS Key ARN or null." } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main.tf
(1 hunks)src/variables.tf
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: component / terraform / Lint (./src/modules/postgresql-user)
- GitHub Check: component / terraform / Lint (./src)
- GitHub Check: component / terraform / Format HCL
- GitHub Check: component / terraform / bats
- GitHub Check: Mergify Merge Protections
- GitHub Check: Mergify Merge Protections
- GitHub Check: Summary
🔇 Additional comments (1)
src/main.tf (1)
11-11
:❓ Verification inconclusive
Verify precedence of
coalesce
arguments
Currently,kms_key_arn = coalesce(module.aurora_postgres.outputs.kms_key_arn, var.kms_key_arn)will always select the module output if it’s non-null, which may mask a user-supplied
var.kms_key_arn
. Please confirm whethermodule.aurora_postgres.outputs.kms_key_arn
is set tonull
when a custom key ARN is provided. If not, swap the arguments to give explicit override precedence:kms_key_arn = coalesce(var.kms_key_arn, module.aurora_postgres.outputs.kms_key_arn)
🏁 Script executed:
#!/bin/bash # Locate the kms_key_arn output in the Aurora Postgres module to confirm its behavior rg -R --include "*.tf" 'output "kms_key_arn"' -n .Length of output: 457
I’ll re-run the search without the invalid
-R
flag to locate anykms_key_arn
definitions in the repo:If these still return nothing (e.g. because the module is remote), please manually verify whether
module.aurora_postgres.outputs.kms_key_arn
ever returns null whenvar.kms_key_arn
is set to ensure the correctcoalesce
argument order.
🏁 Script executed:
#!/bin/bash # Look for output and variable definitions for kms_key_arn across all .tf files rg --with-filename --line-number --context=3 --include '*.tf' 'output "kms_key_arn"' rg --with-filename --line-number --context=3 --include '*.tf' 'variable "kms_key_arn"'Length of output: 1059
I’ll switch to a grep-based search to find any local definitions or references:
🏁 Script executed:
#!/bin/bash # Search for kms_key_arn outputs, variables, and the aurora_postgres module declaration grep -RIn --include='*.tf' 'output "kms_key_arn"' . grep -RIn --include='*.tf' 'variable "kms_key_arn"' . grep -RIn --include='*.tf' 'module "aurora_postgres"' .Length of output: 265
Confirm
coalesce
argument precedenceIt looks like
module.aurora_postgres.outputs.kms_key_arn
comes from a remote module (no localoutput "kms_key_arn"
found), so we can’t verify from source whether it returnsnull
when you supplyvar.kms_key_arn
. Please double-check that behavior and, if the module always emits a non-null ARN, swap the arguments so a user-provided key wins:• File: src/main.tf
Line: 11- kms_key_arn = coalesce(module.aurora_postgres.outputs.kms_key_arn, var.kms_key_arn) + kms_key_arn = coalesce(var.kms_key_arn, module.aurora_postgres.outputs.kms_key_arn)Until you’ve confirmed the module output can be
null
, leave a note or adjust accordingly.
These changes were released in v1.537.0. |
why
kms_key_arn
variable, allowing consumers to supply their own customer-managed KMS keywhat
Default behavior
kms_key_arn
Override behavior
kms_key_arn = "arn:aws:kms:…:key/EXAMPLE"
references
Summary by CodeRabbit