Skip to content

aws-logs: add AccountPolicy L2 construct #34130

Open
@garysassano

Description

@garysassano

Describe the feature

The L2 construct equivalent of CfnAccountPolicy, aimed at reducing boilerplate code and simplifying configuration; it should help to prevent common pitfalls (see #31266).

Use Case

See above.

Proposed Solution

The AccountPolicy construct should accept an input of type AccountPolicyType, an enum with the following possible values:

  • LAMBDA
  • KINESIS_DATA_STREAM
  • DATA_FIREHOSE

Depending on the selected AccountPolicyType, you’ll need to provide a different kind of target. For example, if LAMBDA is specified, you must provide an IFunction. The required permissions for the target resource will be automatically attached when the AccountPolicy is created.

Other Information

Creating an account-level subscription filter involves 4 steps:

  1. Create the target resource for the subscription filter (Lambda, Kinesis Data Stream, or Data Firehose).
  2. Grant CloudWatch Logs permission to use the target resource.
  3. Add a dependency in the CDK resource graph to ensure the subscription filter is not created before the permission is granted.
  4. Create the account-level subscription filter.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.189.0

Environment details (OS name and version, etc.)

Ubuntu 24.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-logsRelated to Amazon CloudWatch Logsfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions