Skip to main content

Backup CodeCommit repositories to S3

Project description

cloudcomponents Logo

@cloudcomponents/cdk-codecommit-backup

Build Status cdkdx typescript python Mentioned in Awesome CDK

Backup CodeCommit repositories to S3

Install

TypeScript/JavaScript:

npm i @cloudcomponents/cdk-codecommit-backup

Python:

pip install cloudcomponents.cdk-codecommit-backup

How to use

import { Construct, Stack, StackProps, Duration } from '@aws-cdk/core';
import { Repository } from '@aws-cdk/aws-codecommit';
import { Schedule } from '@aws-cdk/aws-events';
import { SnsTopic } from '@aws-cdk/aws-events-targets';
import { Topic } from '@aws-cdk/aws-sns';
import { EmailSubscription } from '@aws-cdk/aws-sns-subscriptions';
import {
  BackupBucket,
  S3CodeCommitBackup,
} from '@cloudcomponents/cdk-codecommit-backup';

export class CodeCommitBackupStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const repository = Repository.fromRepositoryName(
      this,
      'Repository',
      process.env.REPOSITORY_NAME as string,
    );

    const backupBucket = new BackupBucket(this, 'BackupBuckt', {
      retentionPeriod: Duration.days(90),
    });

    // The following example runs a task every day at 4am
    const backup = new S3CodeCommitBackup(this, 'S3CodeCommitBackup', {
      backupBucket,
      repository,
      schedule: Schedule.cron({
        minute: '0',
        hour: '4',
      }),
    });

    const backupTopic = new Topic(this, 'BackupTopic');

    backupTopic.addSubscription(
      new EmailSubscription(process.env.DEVSECOPS_TEAM_EMAIL as string),
    );

    backup.onBackupStarted('started', {
      target: new SnsTopic(backupTopic),
    });

    backup.onBackupSucceeded('succeeded', {
      target: new SnsTopic(backupTopic),
    });

    backup.onBackupFailed('failed', {
      target: new SnsTopic(backupTopic),
    });
  }
}

API Reference

See API.md.

Example

See more complete examples.

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudcomponents.cdk-codecommit-backup-1.49.0.tar.gz (79.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file cloudcomponents.cdk-codecommit-backup-1.49.0.tar.gz.

File metadata

  • Download URL: cloudcomponents.cdk-codecommit-backup-1.49.0.tar.gz
  • Upload date:
  • Size: 79.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for cloudcomponents.cdk-codecommit-backup-1.49.0.tar.gz
Algorithm Hash digest
SHA256 e8b3a4066c8b90610c7581f61fe9806b725d035adf2a2b564e2d145a71822a52
MD5 74d73cb0e175e24abc8c4dc1c642cb61
BLAKE2b-256 7d3b4e38e90257e18360e5659fcb4d6b8432430ca4b3e4f6703ad6a197f536c7

See more details on using hashes here.

File details

Details for the file cloudcomponents.cdk_codecommit_backup-1.49.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudcomponents.cdk_codecommit_backup-1.49.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5f0b5ff3614ef252deb5cfd9d2580690742c00d64e0d1f6c2f6d162fa9cbfbb
MD5 7e64c94398f1c4b7e377bccac9a0df3f
BLAKE2b-256 610d68bb0d7998bb8ab82e975194e5870f71d251e9ca120f839b3330a8d66ff1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page