> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/logging/appsec2-aws-61.md).

# An S3 bucket must have a lifecycle configuration misconfiguration detected in code

## Rule Details

|                        |                           |
| ---------------------- | ------------------------- |
| Cortex AppSec Rule ID  | APPSEC2\_AWS\_61          |
| Category - Subcategory | Logging - Retention       |
| Provider               | AWS                       |
| Severity               | MEDIUM                    |
| Framework              | Terraform, Terraform Plan |

## Impact

This rule detects whether an S3 bucket in AWS has a lifecycle configuration or not. A lifecycle configuration on an S3 bucket helps to manage objects so they can be automatically transitioned to other storage classes or expire after a certain period. This is crucial for cost effective data management and storage optimization.

## How to Fix

*Resource:* aws\_s3\_bucket

* *Arguments:* lifecycle\_rule

To fix the issue, it is needed to configure a lifecycle\_rule under the respective S3 bucket in your terraform file specifying the id, status, prefix, transition, and expiration.

## The above code defines a lifecycle configuration rule for the S3 bucket "bucket". The rule "expire" applies to objects with keys beginning with "logs/", transitions those objects to the STANDARD\_IA storage class after 30 days, and then expires the objects 90 days after creation. This helps to reduce costs and ensure correct object lifecycle management. \[source,go]

resource "aws\_s3\_bucket" "bucket" { bucket = "bucket" acl = "private”

## lifecycle\_rule { id = "expire" status = "Enabled" prefix = "logs/" transition { days = 30 storage\_class = "STANDARD\_IA" } expiration { days = 90 } } }


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/logging/appsec2-aws-61.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
