# ObjectLockConfigurationProperty

Places an Object Lock configuration on the specified bucket.

The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket. For more information, see [Locking Objects](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html) .

- Source: Generated at build time
- Type last changed: v2.93.0 · 23 Aug 2023

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_s3 as s3 } from 'aws-cdk-lib';
const objectLockConfigurationProperty: s3.CfnBucket.ObjectLockConfigurationProperty = {
  objectLockEnabled: 'objectLockEnabled',
  rule: {
    defaultRetention: {
      days: 123,
      defaultEventHold: {
        days: 123,
        years: 123,
      },
      mode: 'mode',
      years: 123,
    },
  },
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_s3 as s3

object_lock_configuration_property = s3.CfnBucket.ObjectLockConfigurationProperty(
    object_lock_enabled="objectLockEnabled",
    rule=s3.CfnBucket.ObjectLockRuleProperty(
        default_retention=s3.CfnBucket.DefaultRetentionProperty(
            days=123,
            default_event_hold=s3.CfnBucket.DefaultEventHoldProperty(
                days=123,
                years=123
            ),
            mode="mode",
            years=123
        )
    )
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.s3.*;

ObjectLockConfigurationProperty objectLockConfigurationProperty = ObjectLockConfigurationProperty.builder()
        .objectLockEnabled("objectLockEnabled")
        .rule(ObjectLockRuleProperty.builder()
                .defaultRetention(DefaultRetentionProperty.builder()
                        .days(123)
                        .defaultEventHold(DefaultEventHoldProperty.builder()
                                .days(123)
                                .years(123)
                                .build())
                        .mode("mode")
                        .years(123)
                        .build())
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.S3;

var objectLockConfigurationProperty = new ObjectLockConfigurationProperty {
    ObjectLockEnabled = "objectLockEnabled",
    Rule = new ObjectLockRuleProperty {
        DefaultRetention = new DefaultRetentionProperty {
            Days = 123,
            DefaultEventHold = new DefaultEventHoldProperty {
                Days = 123,
                Years = 123
            },
            Mode = "mode",
            Years = 123
        }
    }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

objectLockConfigurationProperty := &ObjectLockConfigurationProperty{
	ObjectLockEnabled: jsii.String("objectLockEnabled"),
	Rule: &ObjectLockRuleProperty{
		DefaultRetention: &DefaultRetentionProperty{
			Days: jsii.Number(123),
			DefaultEventHold: &DefaultEventHoldProperty{
				Days: jsii.Number(123),
				Years: jsii.Number(123),
			},
			Mode: jsii.String("mode"),
			Years: jsii.Number(123),
		},
	},
}
```

## Properties

- `objectLockEnabled`: string — Indicates whether this bucket has an Object Lock configuration enabled.

  Enable `ObjectLockEnabled` when you apply `ObjectLockConfiguration` to a bucket.

- `rule`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnBucket.ObjectLockRuleProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.CfnBucket.ObjectLockRuleProperty.html) — Specifies the Object Lock rule for the specified object.

  Enable this rule when you apply `ObjectLockConfiguration` to a bucket. If Object Lock is turned on, bucket settings require both `Mode` and a period of either `Days` or `Years` . You cannot specify `Days` and `Years` at the same time. For more information, see [ObjectLockRule](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-objectlockrule.html) and [DefaultRetention](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-defaultretention.html) .
