-
-
Notifications
You must be signed in to change notification settings - Fork 3
Fix iam policy referencing and add KMS #18
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
Fix iam policy referencing and add KMS #18
Conversation
WalkthroughThe pull request modifies Changes
Poem
Suggested labels
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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
|
Important Description is necessary and should not be empty.Kindly provide details with what was changed, why it was changed. |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟠 Require terratestWaiting checks:
|
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/kms-key.tf (1)
1-11: Consider updating the KMS key module version.The configuration looks good with appropriate security settings (key rotation and deletion window). However, consider updating to the latest version 0.12.3 of the cloudposse/kms-key/aws module for potential bug fixes and improvements.
module "kms_key_archive" { source = "cloudposse/kms-key/aws" - version = "0.12.2" + version = "0.12.3"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/kms-key.tf(1 hunks)src/main.tf(6 hunks)
🧰 Additional context used
🪛 Checkov (3.2.334)
src/kms-key.tf
[HIGH] 13-90: Ensure no IAM policies documents allow "*" as a statement's resource for restrictable actions
(CKV_AWS_356)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Mergify Merge Protections
- GitHub Check: Mergify Merge Protections
- GitHub Check: Summary
🔇 Additional comments (7)
src/kms-key.tf (3)
16-27: LGTM! Root account permissions are properly configured.The statement follows AWS best practices by allowing root account access to the KMS key.
29-48: LGTM! CloudTrail permissions follow least privilege principle.The statement correctly restricts CloudTrail's KMS permissions to only necessary encryption operations and uses appropriate conditions to limit scope.
50-89: LGTM! Datadog role permissions are properly secured.The statements provide necessary KMS permissions for Datadog while implementing proper security controls:
- Key usage permissions are limited to essential operations
- Grant management is restricted to AWS services via the
kms:GrantIsForAWSResourceconditionsrc/main.tf (4)
143-145: LGTM! IAM policy reference has been fixed.The change correctly implements the required map of objects structure for the IAM policy, addressing the original issue mentioned in the PR objectives.
172-174: LGTM! Server-side encryption is properly configured.The archive bucket is correctly configured to use KMS encryption with the newly created key.
313-313: LGTM! CloudTrail KMS integration is complete.The CloudTrail module is correctly configured to use the new KMS key for encryption, completing the end-to-end encryption setup.
Line range hint
226-239: Verify the impact of the major version upgrade.While the KMS encryption configuration looks good, upgrading the s3-bucket module from 3.1.2 to 4.10.0 is a major version jump that might include breaking changes.
✅ Verification successful
The version upgrade from 3.1.2 to 4.10.0 is safe to proceed.
The code review shows that none of the breaking changes introduced in version 4.0.0 affect this implementation:
- No usage of deprecated
policyinput- No logging configuration to migrate
- No replication rules to update
- KMS encryption is properly configured
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for breaking changes in the s3-bucket module upgrade # Fetch the changelog curl -s https://raw.githubusercontent.com/cloudposse/terraform-aws-s3-bucket/master/CHANGELOG.md | grep -A 10 "## \[4.0.0\]"Length of output: 126
Script:
#!/bin/bash # Description: Fetch release information using GitHub API for version comparison # Fetch releases between 3.1.2 and 4.10.0 curl -s -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/cloudposse/terraform-aws-s3-bucket/releases" | \ jq -r '.[] | select(.tag_name | startswith("4.") or startswith("3.")) | "\(.tag_name)\n\(.body)"'Length of output: 45008
|
Updated with KMS as per our discussion in office hours. |
| @@ -0,0 +1,90 @@ | |||
| module "kms_key_archive" { | |||
| source = "cloudposse/kms-key/aws" | |||
| version = "0.12.2" | |||
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.
for folks who don't want to kms encrypt this. could we add a variable that sets the enabled field for this module?
| version = "0.12.2" | |
| version = "0.12.2" | |
| enabled = var.enable_kms_encryption |
Also, you'll probably want to output the arn of the kms key
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Thanks @StealthBadger747 for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
💥 This pull request now has conflicts. Could you fix it @StealthBadger747? 🙏 |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
I no longer have the setup to test this, feel free to take what is here and make it work though |
what
I changed how the IAM Bucket policy is reference in order to fix an error I was getting.
Additionally for compliance I have included changes to use CMK KMS as well.
why
I was experiencing this error:
And because https://github.com/cloudposse/terraform-aws-iam-policy/blob/660de2d894c7b4aebd8f98bd061faad5b028a107/variables.tf#L37-L65 requires a map of objects, I needed to change how the policy was being referenced in order to fulfill that requirement.
Other details
I also in my stack needed to add a name, otherwise I'd get the following errors:
Errors:
Summary by CodeRabbit
Summary by CodeRabbit