Skip to content

Conversation

@brucex
Copy link
Contributor

@brucex brucex commented Aug 8, 2025

what

  • allow users to change lifecycle fields
  • different lifecycle parameters for archive vs cloudtrail

why

  • I want to be able to expire objects, i also don't need to move objects to glacier
  • Allows users to set their own lifecycle rules

Summary by CodeRabbit

  • New Features
    • Introduced advanced lifecycle configuration options for archive and CloudTrail storage, allowing more granular control over transitions, expirations, and storage class management.
  • Refactor
    • Consolidated multiple individual lifecycle settings into structured configuration objects for easier management and extensibility.
  • Chores
    • Updated default values and streamlined variable handling for improved clarity and flexibility in storage lifecycle management.

brucex and others added 4 commits August 8, 2025 13:44
- Add expiration_days variable for current object expiration
- Add noncurrent_version_expiration_days variable for old version expiration
- Update lifecycle rules to use variables instead of hardcoded values
- Expiration automatically enables when days > 0

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add variables for all S3 lifecycle rule fields
- Include abort_incomplete_multipart_upload_days
- Add deep archive transition variables
- Add standard IA transition variables
- Add separate cloudtrail-specific glacier transition variables
- All lifecycle behaviors now fully configurable via variables

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Rename lifecycle variables to have cloudtrail_ prefix for clarity
- Add complete set of cloudtrail-specific lifecycle variables
- Separate archive and cloudtrail bucket lifecycle configurations
- All cloudtrail lifecycle behaviors now independently configurable

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Replace individual lifecycle variables with archive_lifecycle_config and cloudtrail_lifecycle_config maps
- Use Terraform optional() function with sensible defaults for all fields
- Clean up variables.tf by removing 20+ individual lifecycle variables
- Maintain backward compatibility through default values
- Improve configuration organization and readability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

Walkthrough

Lifecycle configuration for S3 buckets in the Terraform codebase has been refactored. The previous use of individual variables for lifecycle settings is replaced with structured object variables, archive_lifecycle_config and cloudtrail_lifecycle_config, allowing dynamic and centralized assignment of all lifecycle-related parameters for both archive and CloudTrail buckets.

Changes

Cohort / File(s) Change Summary
Lifecycle Rule Refactor (Main Terraform)
src/main.tf
Lifecycle rule parameters for archive and CloudTrail S3 buckets are now assigned from structured config variables, replacing fixed or default values. Expiration flags are now conditionally set based on config values.
Lifecycle Config Variable Refactor
src/variables.tf
Replaces multiple individual lifecycle variables with two object variables: archive_lifecycle_config and cloudtrail_lifecycle_config, each encapsulating all lifecycle options. Removes now-unneeded individual variables.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Terraform
    participant ArchiveBucketModule
    participant CloudTrailBucketModule

    User->>Terraform: Apply configuration
    Terraform->>ArchiveBucketModule: Pass archive_lifecycle_config object
    Terraform->>CloudTrailBucketModule: Pass cloudtrail_lifecycle_config object
    ArchiveBucketModule->>ArchiveBucketModule: Dynamically assign lifecycle rules from config
    CloudTrailBucketModule->>CloudTrailBucketModule: Dynamically assign lifecycle rules from config
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

A rabbit hopped through fields of code,
Refactoring buckets in lifecycle mode.
From scattered vars to configs neat,
Now all the rules are quite complete!
With objects tidy, reviews less scary—
The Terraform garden grows less hairy.
🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mergify mergify bot requested review from a team August 8, 2025 19:23
@mergify mergify bot added the triage Needs triage label Aug 8, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (3)
src/variables.tf (2)

24-40: Re-evaluate default Glacier transition for archives (enabled=true by default)

The PR goal is “flexible lifecycle rules” and avoiding automatic Glacier moves when undesired. Defaulting enable_glacier_transition = true (365 days) keeps Glacier enabled by default. If you intend an opt-in posture, set default to false; otherwise, please confirm this preserves prior behavior for existing users.


24-40: Breaking change note: variable interface changed to objects — plan migration path

Switching from discrete variables to object configs breaks existing tfvars. Either:

  • Provide a deprecation bridge (keep old variables and merge into new object via locals), or
  • Document a migration guide and bump component version accordingly.

I can draft a migration snippet (locals + merge) if you prefer a non-breaking path.

Also applies to: 42-58

src/main.tf (1)

176-189: Optional: guard against mis-ordered transitions at the module edge

If you don’t add variable validations, you can enforce ordering here to reduce plan-time failures:

+      # Optional guards; remove if validations are added at variables layer
+      standard_transition_days = var.archive_lifecycle_config.standard_transition_days > 0
+        && var.archive_lifecycle_config.standard_transition_days < var.archive_lifecycle_config.glacier_transition_days ? var.archive_lifecycle_config.standard_transition_days : var.archive_lifecycle_config.standard_transition_days
+      glacier_transition_days  = var.archive_lifecycle_config.glacier_transition_days > 0
+        && var.archive_lifecycle_config.glacier_transition_days < var.archive_lifecycle_config.deeparchive_transition_days ? var.archive_lifecycle_config.glacier_transition_days : var.archive_lifecycle_config.glacier_transition_days

Prefer validations in variables.tf for clearer UX; this is just a fallback idea.

Also applies to: 240-252

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f57e5f4 and 40054eb.

📒 Files selected for processing (2)
  • src/main.tf (2 hunks)
  • src/variables.tf (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Summary
🔇 Additional comments (2)
src/variables.tf (1)

44-45: No action needed: downstream module supports null for abort_incomplete_multipart_upload_days

In cloudposse/s3-bucket v4.10.0, omitting or setting abort_incomplete_multipart_upload_days to null disables the abort-incomplete-multipart-upload feature. Your default of null in src/variables.tf is therefore safe and requires no changes.

[Citation: cloudposse/s3-bucket docs (v4.10.0)]

src/main.tf (1)

185-188: Nice: conditional enablement of expirations

Tying enable_current_object_expiration and enable_noncurrent_version_expiration to days > 0 is clean and avoids “enabled with zero days” traps.

Also applies to: 249-252

@mergify mergify bot added the needs-test Needs testing label Aug 13, 2025
Copy link

@oycyc oycyc left a comment

Choose a reason for hiding this comment

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

👍

@oycyc
Copy link

oycyc commented Aug 14, 2025

/terratest

@mergify mergify bot requested a review from a team August 14, 2025 00:23
@mergify mergify bot removed the triage Needs triage label Aug 14, 2025
@oycyc oycyc added enhancement New feature or request feature New functionality minor New features that do not break anything and removed needs-test Needs testing labels Aug 14, 2025
@github-actions
Copy link
Contributor

There are no real tests for this component. So we set terratest statuses to successful execution without running any tests

@mergify
Copy link

mergify bot commented Aug 14, 2025

Thanks @brucex 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 #pr-reviews channel.

@oycyc oycyc added this pull request to the merge queue Aug 14, 2025
Merged via the queue into cloudposse-terraform-components:main with commit 40bce16 Aug 14, 2025
19 checks passed
@github-actions
Copy link
Contributor

These changes were released in v1.536.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature New functionality minor New features that do not break anything

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants