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.50.0.tar.gz (78.7 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.50.0.tar.gz.

File metadata

  • Download URL: cloudcomponents.cdk-codecommit-backup-1.50.0.tar.gz
  • Upload date:
  • Size: 78.7 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.10

File hashes

Hashes for cloudcomponents.cdk-codecommit-backup-1.50.0.tar.gz
Algorithm Hash digest
SHA256 dc1de28fc077b9087dc146bc5dcd1672f1bbef77bc5391893c70fb430090bc6f
MD5 3c97c5c79a3b89a36a437abb8d82e34d
BLAKE2b-256 e07abd5f9b42ba10abea683a87ddcf858271bc7e7948046735694b9f0bc938c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cloudcomponents.cdk_codecommit_backup-1.50.0-py3-none-any.whl
Algorithm Hash digest
SHA256 018667bb57b97186d437bb27a007cbee7460616ebbef99a8ca51a0d2ee04bd23
MD5 1d4857a2e9612275d7fb79bd10ff01f7
BLAKE2b-256 73aa0caa5314bd24ba90b1670fafdd7b3a321089c1a3a8a957ce4fa8a8b23609

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