npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

aws-daily-cloudwatch-logs-archiver

v3.1.5

Published

AWS CloudWatch Logs daily archive to s3 bucket

Downloads

704

Readme

AWS Daily CloudWatch Logs Archive Stack

GitHub npm version GitHub Workflow Status (branch) GitHub release (latest SemVer) View on Construct Hub

An AWS CDK construct that archives CloudWatch Logs to S3 every day. Log groups are selected by resource tags; the previous calendar day's logs are exported to a secure S3 bucket on a fixed schedule (13:01 UTC).

Features

  • Scheduled daily export – EventBridge Scheduler runs once per day at 13:01 UTC.
  • Tag-based selection – Uses the Resource Groups Tagging API to find CloudWatch Log groups by tag (e.g. DailyLogExport = Yes); only tagged groups are archived.
  • Durable Lambda execution – Export logic runs in a single Lambda with AWS Durable Execution, creating export tasks and polling until completion (up to 2 hours) so many log groups can be processed in one run.
  • Structured S3 layout – Exports the previous calendar day (00:00:00–23:59:59.999 UTC) per log group to S3 with prefix {logGroupName}/{YYYY}/{MM}/{DD}/.
  • Secure bucket – S3 bucket from @gammarers/aws-secure-log-bucket with a resource policy allowing CloudWatch Logs to deliver export data.
  • Versioned invocation – Lambda alias live is used as the scheduler target for stable, versioned deployments.

How it works

  • Schedule: EventBridge Scheduler runs once per day at 13:01 UTC.
  • Target selection: The scheduler invokes a Lambda with a tag key and values. The Lambda uses the Resource Groups Tagging API to find all CloudWatch Log groups that have that tag, then exports each group.
  • Durable Lambda: The export logic runs inside a single Lambda using AWS Durable Execution. The function creates export tasks, polls until they complete (with retries), and can run up to 2 hours so many log groups can be processed in one run.
  • Export: For each log group, a CreateExportTask is issued for the previous calendar day (00:00:00–23:59:59.999 UTC). Objects are written to S3 with the prefix {logGroupName}/{YYYY}/{MM}/{DD}/.

You tag the log groups you want to include (e.g. DailyLogExport = Yes); only those groups are archived.

Resources created

  • S3 bucket – Secure log bucket (from @gammarers/aws-secure-log-bucket) with a resource policy allowing CloudWatch Logs to deliver export data.
  • Lambda function – Durable execution, ARM64, 15-minute timeout per invocation, 2-hour durable execution limit. Writes to the bucket and uses the tagging API.
  • Lambda execution role – Basic + Durable Execution managed policies plus S3 permissions.
  • Lambda log group – 3-month retention for the archiver's own logs.
  • Lambda aliaslive, used as the scheduler target for versioned deployments.
  • EventBridge Scheduler – Cron schedule and target (Lambda invoke with tagKey and tagValues in the payload).

Architecture

architecture

Installation

npm

npm install aws-daily-cloudwatch-logs-archiver

yarn

yarn add aws-daily-cloudwatch-logs-archiver

Usage

Use the construct inside your stack and pass the tag key and values used to select log groups. Only log groups that have this tag (with one of the given values) will be archived.

import { DailyCloudWatchLogsArchiver } from 'aws-daily-cloudwatch-logs-archiver';

new DailyCloudWatchLogsArchiver(this, 'DailyCloudWatchLogsArchiver', {
  targetResourceTag: {
    key: 'DailyLogExport',
    values: ['Yes'],
  },
});

Alternatively, use the dedicated stack that contains the construct:

import { DailyCloudWatchLogsArchiveStack } from 'aws-daily-cloudwatch-logs-archiver';

new DailyCloudWatchLogsArchiveStack(app, 'DailyCloudWatchLogsArchiveStack', {
  targetResourceTag: {
    key: 'DailyLogExport',
    values: ['Yes'],
  },
});

Ensure the CloudWatch Log groups you want to archive are tagged accordingly (e.g. DailyLogExport = Yes).

Options

| Option | Type | Description | |--------|------|-------------| | targetResourceTag | TargetResourceTagProperty | Tag filter to identify which log groups to archive daily. |

TargetResourceTagProperty

| Property | Type | Description | |----------|------|-------------| | key | string | Tag key to filter log groups (e.g. "DailyLogExport", "Environment"). | | values | string[] | Tag values to match; log groups with any of these values are included (e.g. ['Yes']). |

Requirements

  • Node.js >= 20.0.0
  • AWS CDK (peer): aws-cdk-lib ^2.232.0
  • Constructs (peer): constructs ^10.0.5

One-off or custom exports

For one-time or ad-hoc exports (e.g. historical date ranges), see AWS CloudWatch Logs Exporter. It can produce the same S3 key layout.

License

This project is licensed under the Apache-2.0 License.