This repository is for replicating codecommit repositories across accounts
If you are looking for replicating codecommit repositories across regions on same account, check Picapica out.
- Nodejs 14.x
- AWS Account and Locally configured AWS credential
Install project dependencies
$ npm i -g [email protected]
$ cd infra
$ npm i
$ cdk bootstrap
This CDK project is consists of 2 parts,
OriginStack must be deployed on the origin account having repositories to replicate to other accounts
Edit lib/interfaces/config.ts and fill variables under Origin namespace
$ vim lib/interfaces/config.ts
Here is an example of the configuration for origin
export namespace Origin {
export const AccountId = '213809038850'
export const Region = 'ap-northeast-2'
export const RoleName = `${App.Namespace}ReplicationRole`
export const RoleArn = `arn:aws:iam::${AccountId}:role/${RoleName}`
export const ReplicaAccounts: IReplicaAccount[] = [
{
AccountId: '924918149261',
Region: 'ap-northeast-2',
EventBusName: App.EventBusName,
},
{
AccountId: '735029250372',
Region: 'ap-northeast-1',
EventBusName: App.EventBusName,
}
]
export const RepositoryNames: string[] = ['myapp', 'otherapp']
export const BranchNames: string[] = ['main', 'release']
}
$ cdk deploy CrocaOriginStack --require-approval never --profile default
ReplicaStack should be deployed on the replica account having repositories to be replicated from the origin account
Edit lib/interfaces/config.ts and fill variables under Replica namespace
$ vim lib/interfaces/config.ts
Here is an example of the configuration for replica
export namespace Replica {
export const AccountId = '924918149261' // 12 digit number
export const Repositories: IRepository[] = [
{
RepositoryName: 'myapp',
BranchName: 'main',
Region: 'us-west-2',
},
{
RepositoryName: 'otherapp',
BranchName: 'release',
Region: 'ap-northeast-2',
},
]
}
$ cdk deploy CrocaReplicaStack --require-approval never --profile replica
$ aws codecommit create-repository --repository-name myapp
$ pip install git-remote-codecommit
$ git clone codecommit::ap-northeast-2//myapp myapp
$ cd myapp
$ cat > README.md
# This is MyApp for testing
$ git add README.md
$ git commit -m "add README"
destroy provisioned cloud resources for both accounts
$ cdk destroy "*"