Giter VIP home page Giter VIP logo

croca's Introduction

Croca - Replicate Cross Account Codecommint Repositories

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.

Prerequisites

  • Nodejs 14.x
  • AWS Account and Locally configured AWS credential

Installation

Install project dependencies

$ npm i -g [email protected]

$ cd infra
$ npm i
$ cdk bootstrap

Usage

This CDK project is consists of 2 parts,

OriginStack

OriginStack must be deployed on the origin account having repositories to replicate to other accounts

Setup config

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']
}

Deploy OriginStack on Origin Account

$ cdk deploy CrocaOriginStack --require-approval never --profile default

ReplicaStack

ReplicaStack should be deployed on the replica account having repositories to be replicated from the origin account

Setup config

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',
    },
  ]
}

Deploy ReplicaStack on Replica Account

$ cdk deploy CrocaReplicaStack --require-approval never --profile replica

Test

$ 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"

Cleanup

destroy provisioned cloud resources for both accounts

$ cdk destroy "*"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.