-
Notifications
You must be signed in to change notification settings - Fork 0
Enable KMS encryption for S3 buckets #6
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,9 @@ inputs = { | |
| enable_versioning = true # Enable versioning for production | ||
| enable_lifecycle_rules = true # Enable lifecycle rules for production | ||
|
|
||
| # KMS encryption | ||
| kms_key_arn = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012" | ||
|
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, locate the terragrunt.hcl file and verify it exists
find . -name "terragrunt.hcl" -o -name "*terragrunt*" | head -20Repository: coderabbitai/rabbits-playground Length of output: 468 🏁 Script executed: # Look for policy documentation or S3 encryption standards in the repo
find . -type f \( -name "*.md" -o -name "*.txt" -o -name "*.json" \) | xargs rg -l "S3.*policy|encryption.*standard|CISO" 2>/dev/null | head -20Repository: coderabbitai/rabbits-playground Length of output: 57 🏁 Script executed: # Check for AWS account ID patterns and environment configs
rg "123456789012|account.*id|aws.*account" -t hcl -t json -A 2 | head -40Repository: coderabbitai/rabbits-playground Length of output: 102 🏁 Script executed: # Read the actual prod/s3/terragrunt.hcl file
cat -n ./prod/s3/terragrunt.hclRepository: coderabbitai/rabbits-playground Length of output: 806 🏁 Script executed: # Search for policy, compliance, or CISO-related documentation
rg "policy|compliance|CISO|encryption.*standard|SSE-KMS" -i --type-list | head -5
rg "policy|compliance|CISO|encryption.*standard|SSE-KMS" -i . 2>/dev/null | head -30Repository: coderabbitai/rabbits-playground Length of output: 2645 🏁 Script executed: # Check dev environment S3 config to compare account IDs
cat -n ./dev/s3/terragrunt.hclRepository: coderabbitai/rabbits-playground Length of output: 798 🏁 Script executed: # Search for any documentation or policy files more thoroughly
find . -type f \( -name "*.md" -o -name "*.txt" -o -name "*.rst" -o -name "README*" \) | xargs cat 2>/dev/null | grep -i "policy\|compliance\|ciso\|encryption.*standard" -A 2 -B 2 2>/dev/null | head -50Repository: coderabbitai/rabbits-playground Length of output: 57 🏁 Script executed: # Check the S3 module implementation to see how KMS is configured
cat -n ./modules/s3/main.tf | head -80Repository: coderabbitai/rabbits-playground Length of output: 2599 🏁 Script executed: # Look for variables and validation rules in S3 module
cat -n ./modules/s3/variables.tf 2>/dev/null || echo "variables.tf not found"Repository: coderabbitai/rabbits-playground Length of output: 989 🏁 Script executed: # Check root terragrunt config for environment-specific policies
cat -n ./terragrunt.hcl ./prod/terragrunt.hcl 2>/dev/null | head -60Repository: coderabbitai/rabbits-playground Length of output: 2063 Replace placeholder KMS ARN with actual production key before deployment. The KMS ARN contains placeholder values (account ID Note: The suggestion to use AWS Systems Manager Parameter Store for the KMS ARN is optional—passing the ARN directly as a Terraform variable is standard practice. 🤖 Prompt for AI Agents |
||
|
|
||
| # CORS configuration | ||
| allowed_origins = ["https://example.com", "https://www.example.com"] | ||
| } | ||
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.
🧩 Analysis chain
🌐 Web query:
AWS account ID 123456789012 placeholder documentation💡 Result:
AWS documentation commonly uses the 12-digit number 123456789012 as an example/placeholder AWS account ID (not a real account). Examples appear throughout official docs (ARN and API examples, CloudFormation return values, etc.). [1][2][3]
Sources:
🌐 Web query:
hardcoding KMS ARN in code security best practices💡 Result:
Short answer
Don’t hardcode KMS key ARNs in application source. Use identity/metadata (IAM roles), configuration/secret stores, and aliases so keys aren’t embedded in code and you can rotate/repoint keys without code changes. (docs.aws.amazon.com)
What to do instead (concise)
Operational controls
If you want, I can:
Citations:
🌐 Web query:
S3 Encryption Standards policy CISO approval requirements💡 Result:
Short answer — who/what the CISO should approve for an S3 Encryption Standards policy:
Sources:
🌐 Web query:
KMS key policy requirements S3 service principal encryption💡 Result:
Summary — what a KMS key policy must grant for S3 to perform SSE‑KMS encryption/decryption
Minimal example key‑policy statement (replace placeholders)
{
"Sid": "AllowS3ToUseKeyForSSEKMS",
"Effect": "Allow",
"Principal": { "Service": "s3.amazonaws.com" },
"Action": [
"kms:GenerateDataKey",
"kms:Decrypt"
],
"Resource": "",
"Condition": {
"StringEquals": {
"kms:ViaService": "s3.us-east-1.amazonaws.com",
"AWS:SourceAccount": "111122223333"
},
"ArnLike": {
"AWS:SourceArn": "arn:aws:s3:::example-bucket/"
}
}
}
Notes / references
Sources: [1] AWS S3 — Permission requirements for S3 Tables SSE‑KMS encryption; [2] AWS KMS — condition keys (kms:ViaService); [3] AWS S3 — Using server‑side encryption with AWS KMS keys (SSE‑KMS); [4] AWS Config KMS key policy example.
Replace placeholder account ID and remove hardcoded KMS ARN from version control.
This configuration has several issues:
Placeholder Account ID: The account ID
123456789012is a standard AWS documentation placeholder—replace it with the actual AWS account ID.Hardcoded ARN in Version Control: Per AWS KMS best practices, avoid hardcoding KMS key ARNs in code or infrastructure files. Store the key identifier (ARN, key ID, or alias) in a secure configuration store such as AWS Secrets Manager, Systems Manager Parameter Store, or infrastructure-as-code variables that aren't checked into version control. This allows key rotation and repointing without code changes.
KMS Key Policy: Ensure the key policy grants the S3 service principal (
s3.amazonaws.com) the following actions:kms:GenerateDataKeykms:DecryptRestrict these permissions using conditions like
kms:ViaService(e.g.,s3.us-east-1.amazonaws.com) andAWS:SourceAccountto scope access appropriately. Verify policy is set on the KMS key itself, not only in IAM policies.🤖 Prompt for AI Agents