# LogRetentionProps

Construction properties for a LogRetention.

Used as props by: [LogRetention](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogRetention.html)

- Source: [`aws-logs/lib/log-retention.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-logs/lib/log-retention.ts#L13)
- Type last changed: v2.37.0 · 9 Aug 2022

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
import { aws_logs as logs } from 'aws-cdk-lib';

declare const role: iam.Role;
const logRetentionProps: logs.LogRetentionProps = {
  logGroupName: 'logGroupName',
  retention: logs.RetentionDays.ONE_DAY,

  // the properties below are optional
  logGroupRegion: 'logGroupRegion',
  logRetentionRetryOptions: {
    base: cdk.Duration.minutes(30),
    maxRetries: 123,
  },
  removalPolicy: cdk.RemovalPolicy.DESTROY,
  role: role,
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_iam as iam
from aws_cdk import aws_logs as logs

# role: iam.Role

log_retention_props = logs.LogRetentionProps(
    log_group_name="logGroupName",
    retention=logs.RetentionDays.ONE_DAY,

    # the properties below are optional
    log_group_region="logGroupRegion",
    log_retention_retry_options=logs.LogRetentionRetryOptions(
        base=cdk.Duration.minutes(30),
        max_retries=123
    ),
    removal_policy=cdk.RemovalPolicy.DESTROY,
    role=role
)
```

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.*;
import software.amazon.awscdk.services.iam.*;
import software.amazon.awscdk.services.logs.*;

Role role;

LogRetentionProps logRetentionProps = LogRetentionProps.builder()
        .logGroupName("logGroupName")
        .retention(RetentionDays.ONE_DAY)

        // the properties below are optional
        .logGroupRegion("logGroupRegion")
        .logRetentionRetryOptions(LogRetentionRetryOptions.builder()
                .base(Duration.minutes(30))
                .maxRetries(123)
                .build())
        .removalPolicy(RemovalPolicy.DESTROY)
        .role(role)
        .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;
using Amazon.CDK.AWS.IAM;
using Amazon.CDK.AWS.Logs;

Role role;

var logRetentionProps = new LogRetentionProps {
    LogGroupName = "logGroupName",
    Retention = RetentionDays.ONE_DAY,

    // the properties below are optional
    LogGroupRegion = "logGroupRegion",
    LogRetentionRetryOptions = new LogRetentionRetryOptions {
        Base = Duration.Minutes(30),
        MaxRetries = 123
    },
    RemovalPolicy = RemovalPolicy.DESTROY,
    Role = role
};
```

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"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var role Role

logRetentionProps := &LogRetentionProps{
	LogGroupName: jsii.String("logGroupName"),
	Retention: awscdk.Aws_logs.RetentionDays_ONE_DAY,

	// the properties below are optional
	LogGroupRegion: jsii.String("logGroupRegion"),
	LogRetentionRetryOptions: &LogRetentionRetryOptions{
		Base: cdk.Duration_Minutes(jsii.Number(30)),
		MaxRetries: jsii.Number(123),
	},
	RemovalPolicy: cdk.RemovalPolicy_DESTROY,
	Role: role,
}
```

## Properties

- `logGroupName`: string (required) — The log group name.

- `logGroupRegion`: string — The region where the log group should be created.

  **Default:** same region as the stack

- `logRetentionRetryOptions`: [LogRetentionRetryOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogRetentionRetryOptions.html) — Retry options for all AWS API calls.

  **Default:** AWS SDK default retry options

- `removalPolicy`: [RemovalPolicy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.RETAIN — The removalPolicy for the log group when the stack is deleted.

- `retention`: [RetentionDays](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.RetentionDays.html) (required) — The number of days log events are kept in CloudWatch Logs.

- `role`: [IRole](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The IAM role for the Lambda function associated with the custom resource.

  **Default:** A new role is created
