---
title: "S3 bucket lock configuration disabled Description"
canonical: "https://kb.cynergy.app/space/MD/1209663489/S3%20bucket%20lock%20configuration%20disabled%20Description"
format: markdown
---
# Description

Amazon S3's Object Lock feature prevents deletion of object versions during a defined retention period, enforcing data retention policies and aiding regulatory compliance. It supports two retention methods: fixed retention periods, which lock objects for a set time, and legal holds, which persist indefinitely until removed. When combined with versioning, Object Lock secures objects in an immutable state, preventing changes and deletions, providing additional protection and helping meet data protection standards.

# Fix - Runtime

## AWS Console

1. Sign in to AWS Management Console.
2. Navigate to S3 dashboard at [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/).
3. Click + Create bucket button to start the setup process.
4. Within Create bucket dialog box, perform the following:
5. For step 1: Name and region:
6. Provide a unique name for the new bucket in the Bucket name box.
7. From Region dropdown box, select the AWS region where the new S3 bucket will be created.
8. From Copy settings from an existing bucket dropdown list, select the name of the S3 bucket that you want to re-create.
9. Click Next to continue the process.
10. For step 2: Configure options:
11. Under Versioning, select Keep all versions of an object in the same bucket checkbox to enable S3 versioning for the bucket. S3 Object Lock requires S3 object versioning.
12. Click the Advanced settings tab to shown the advanced configuration settings.
13. Under Object lock, select Permanently allow objects in this bucket to be locked checkbox to enable S3 Object Lock feature for the new bucket.
14. Click Next.
15. For step 3: Set permissions, set any required permissions or leave the settings unchanged to reflect the source bucket permissions configuration. Click Next to continue.
16. For step 4: Review, verify the resource configuration details, then click Create bucket to create the new S3 bucket.
17. Click on the name of the S3 bucket created at the previous step.
18. Select the Properties tab from the S3 dashboard top menu to view bucket properties.
19. In the Advanced settings section, click on the Object Lockbox to access the feature configuration panel, where you can define the automatic settings for the objects that are uploaded without object lock configuration.
20. Inside the Object Lock box, select one of the following retention modes. These retention modes apply different levels of protection to the objects within the bucket chosen:
21. Select Enable Governance mode so that users cannot overwrite or delete an S3 object version or alter its lock settings unless they have special permissions (e.g., root account). Governance mode enables you to protect objects against deletion by most users while still allowing you to grant some users permission to alter the retention settings or delete the object if required. In the Retention period box, enter the number of days required to protect an object version. Click Save to apply the changes.
22. Select Enable compliance mode so that a protected object version cannot be overwritten or deleted by any user, including the root account user. Once an S3 object is locked in Compliance mode, its retention mode cannot be reconfigured, and its retention period cannot be shortened. This retention mode ensures that an object version can't be overwritten or deleted for the duration of the retention period specified in the Retention period box. Click Save to apply the changes.
23. Now, you can transfer the necessary S3 objects from the source bucket, the one with the Object Lock feature disabled, to the destination bucket, the one that has Object Lock enabled.
24. Repeat steps no. 3 – 9 to enable and configure Amazon S3 Object Lock for other S3 buckets available within your AWS account.

## CLI Command

1. Run the create-bucket command (OSX/Linux/UNIX) to (re)create the required Amazon S3 bucket and enable the S3 Object Lock feature for all the objects uploaded to this bucket by using the --object-lock-enabled-for-bucket command parameter:

```
aws s3api create-bucket
    --bucket cc-project5-protected-logs
    --region us-east-1
    --acl private
    --object-lock-enabled-for-bucket

```

1. The command output should return the name of the new Amazon S3 bucket:

```
{
    "Location": "/cc-project5-protected-logs"
}

```

1. Define the Object Lock feature configuration parameters by specifying the retention mode and retention period for the new S3 bucket. The following example enables Governance retention mode for 90 days. Governance mode ensures that users cannot overwrite or delete an S3 object version or alter its lock settings unless they have special permissions (e.g. root account access). Governance mode enables you to protect objects against deletion by most users while still allowing you to grant some users permission to alter the retention settings or delete the object if required. Save these configuration parameters to a JSON file named object-lock-config.json:

```
{
  "ObjectLockEnabled": "Enabled",
  "Rule": {
    "DefaultRetention": {
      "Mode": "GOVERNANCE",
      "Days": 90
    }
  }
}

```

1. Run put-object-lock-configuration command (OSX/Linux/UNIX) using the configuration parameters defined at the previous step (i.e. object-lock-config.json) to apply your S3 Object Lock configuration to the newly created bucket (the command does not produce an output):

```
aws s3api put-object-lock-configuration
    --bucket cc-project5-protected-logs
    --object-lock-configuration file://object-lock-config.json

```

1. Transfer the necessary S3 objects from the source bucket, the one with Object Lock feature disabled, to the destination bucket, the one with S3 Object Lock enabled, created at the previous steps.
2. Repeat steps no. 1 – 5 to enable and configure Amazon S3 Object Lock for other S3 buckets available in your AWS account.

# Fix - Build time

## Terraform

- **Resource:** aws_s3_bucket
- **Argument:** object_lock_enabled

```
resource "aws_s3_bucket" "test" {
   ...
+  object_lock_configuration = {
+     object_lock_enabled = "Enabled"
+  }
}
```