Add support for S3 lifecycle policy management in the GitLab Environment Toolkit (AWS)
Description:
The GitLab Environment Toolkit (GET) currently supports enabling S3 bucket versioning through Terraform but does not provide a way to configure S3 lifecycle policies.
This creates a gap, because enabling versioning without lifecycle management causes deleted or replaced objects to remain in the bucket indefinitely, leading to increased storage costs.
The Toolkit documentation for GCP mentions that when versioning is enabled in Google Cloud Storage (via the object_storage_versioning flag), users are advised to manually configure Object Lifecycle Management to remove older object versions but no equivalent reccomendation exists for AWS.
At the moment, our only options are:
- Add custom Terraform files to manage lifecycle policies, which must be re-mounted every time the Toolkit container runs.
- Edit the existing Toolkit Terraform code, which is overwritten whenever the container updates.
- Apply lifecycle rules manually in AWS, which leads to Terraform drift.
Adding native support in GET to define S3 lifecycle configurations (for example, via an optional variable) would ensure consistent management across environments and prevent indefinite retention of versioned objects.
Benefit:
- Prevents accumulation ofnon current object versions when versioning is enabled.
- Eliminates manual setup and drift by keeping configuration in Terraform.