LogGroupProps

class aws_cdk.aws_logs.LogGroupProps(*, data_protection_policy=None, deletion_protection_enabled=None, encryption_key=None, field_index_policies=None, log_group_class=None, log_group_name=None, removal_policy=None, retention=None)

Bases: object

Properties for a LogGroup.

Parameters:
  • data_protection_policy (Optional[DataProtectionPolicy]) – Data Protection Policy for this log group. Default: - no data protection policy

  • deletion_protection_enabled (Optional[bool]) – Indicates whether deletion protection is enabled for this log group. When enabled, deletion protection blocks all deletion operations until it is explicitly disabled. Default: false

  • encryption_key (Optional[IKeyRef]) – The KMS customer managed key to encrypt the log group with. Default: Server-side encryption managed by the CloudWatch Logs service

  • field_index_policies (Optional[Sequence[FieldIndexPolicy]]) – Field Index Policies for this log group. Default: - no field index policies for this log group.

  • log_group_class (Optional[LogGroupClass]) – The class of the log group. Possible values are: STANDARD and INFREQUENT_ACCESS. INFREQUENT_ACCESS class provides customers a cost-effective way to consolidate logs which supports querying using Logs Insights. The logGroupClass property cannot be changed once the log group is created. Default: LogGroupClass.STANDARD

  • log_group_name (Optional[str]) – Name of the log group. Default: Automatically generated

  • removal_policy (Optional[RemovalPolicy]) – Determine the removal policy of this log group. Normally you want to retain the log group so you can diagnose issues from logs even after a deployment that no longer includes the log group. In that case, use the normal date-based retention policy to age out your logs. Default: RemovalPolicy.Retain

  • retention (Optional[RetentionDays]) – How long, in days, the log contents will be retained. To retain all logs, set this value to RetentionDays.INFINITE. Default: RetentionDays.TWO_YEARS

ExampleMetadata:

fixture=default infused

Example:

repository = ecr.Repository(self, "TestRepository",
    repository_name="test-agent-runtime"
)

agent_runtime_artifact = agentcore.AgentRuntimeArtifact.from_ecr_repository(repository, "v1.0.0")

# Use a /aws/vendedlogs/ log group for same-account delivery without explicit resource policy
log_group = logs.LogGroup(self, "RuntimeLogGroup",
    log_group_name="/aws/vendedlogs/bedrock-agentcore/my-runtime"
)

agentcore.Runtime(self, "test-runtime",
    runtime_name="test_runtime",
    agent_runtime_artifact=agent_runtime_artifact,
    tracing_enabled=True,
    logging_configs=[agentcore.LoggingConfig(
        log_type=agentcore.LogType.APPLICATION_LOGS,
        destination=agentcore.LoggingDestination.cloud_watch_logs(log_group)
    )
    ],
    manage_delivery_resource_policy=False
)

Attributes

data_protection_policy

Data Protection Policy for this log group.

Default:
  • no data protection policy

deletion_protection_enabled

Indicates whether deletion protection is enabled for this log group.

When enabled, deletion protection blocks all deletion operations until it is explicitly disabled.

Default:

false

encryption_key

The KMS customer managed key to encrypt the log group with.

Default:

Server-side encryption managed by the CloudWatch Logs service

field_index_policies

Field Index Policies for this log group.

Default:
  • no field index policies for this log group.

log_group_class

STANDARD and INFREQUENT_ACCESS.

INFREQUENT_ACCESS class provides customers a cost-effective way to consolidate logs which supports querying using Logs Insights. The logGroupClass property cannot be changed once the log group is created.

Default:

LogGroupClass.STANDARD

Type:

The class of the log group. Possible values are

log_group_name

Name of the log group.

Default:

Automatically generated

removal_policy

Determine the removal policy of this log group.

Normally you want to retain the log group so you can diagnose issues from logs even after a deployment that no longer includes the log group. In that case, use the normal date-based retention policy to age out your logs.

Default:

RemovalPolicy.Retain

retention

How long, in days, the log contents will be retained.

To retain all logs, set this value to RetentionDays.INFINITE.

Default:

RetentionDays.TWO_YEARS