Backup CodeCommit repositories to S3
Project description
@cloudcomponents/cdk-codecommit-backup
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 { BackupBucket, S3CodeCommitBackup } from '@cloudcomponents/cdk-codecommit-backup';
import { Duration, Stack, StackProps } from 'aws-cdk-lib';
import { Repository } from 'aws-cdk-lib/aws-codecommit';
import { Schedule } from 'aws-cdk-lib/aws-events';
import { SnsTopic } from 'aws-cdk-lib/aws-events-targets';
import { Topic } from 'aws-cdk-lib/aws-sns';
import { EmailSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';
import { Construct } from 'constructs';
export class CodeCommitBackupStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
if (typeof process.env.REPOSITORY_NAME === 'undefined') {
throw new Error('environment variable REPOSITORY_NAME undefined');
}
const repository = Repository.fromRepositoryName(this, 'Repository', process.env.REPOSITORY_NAME);
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');
if (process.env.DEVSECOPS_TEAM_EMAIL) {
backupTopic.addSubscription(new EmailSubscription(process.env.DEVSECOPS_TEAM_EMAIL));
}
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cloudcomponents.cdk-codecommit-backup-2.2.0.tar.gz.
File metadata
- Download URL: cloudcomponents.cdk-codecommit-backup-2.2.0.tar.gz
- Upload date:
- Size: 148.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b3657d0c6bfc176f54c1d7bd0735ccd0f64bfd8e4ac24db666cf9d9a5dad07e
|
|
| MD5 |
66a77a4aaa889c847210c2f71cc3a5ca
|
|
| BLAKE2b-256 |
c7ab5adb75168955167530c470008abf63b841ab866010df29af16f8c5c7a6e9
|
File details
Details for the file cloudcomponents.cdk_codecommit_backup-2.2.0-py3-none-any.whl.
File metadata
- Download URL: cloudcomponents.cdk_codecommit_backup-2.2.0-py3-none-any.whl
- Upload date:
- Size: 146.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e943d502ee4d4ef1232a4a108b52c16344a8834739f66e82ccfc763f5332aa8
|
|
| MD5 |
00dbcd8288c173a2a157141d151851a2
|
|
| BLAKE2b-256 |
b694ffad4da39c96bb1ffb0b89a272b29a8cd8f24a57f1987ec728d66024778e
|