How the Deep State is Stealing Your Freedom

If conspiracy is defined as an evil or treacherous plan formulated in secret by two or more persons to commit an unlawful act by deceitful or unlawful means…than I assure you, we are all dealing with…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Github Organization as a Code

Github became de-facto standard code storage platform for all types of organizations, from small startups to huge corporations. While a company evolves and grows it will face the need for keeping code organized, structured and secured. Of course, it can be done by a sysadmin person while you have one team and couple members. But what about 5 teams, 10 teams? At some point, it will become extremely hard to keep track on naming convention and access permissions for many users, teams, and repositories.

Luckily most of this problems can be solved by infrastructure management tool that has been around for a while: Terraform. Terraform provides an ability to manage infrastructure as a code on different platforms like AWS, Azure, Kubernetes and also Github.

To check and apply our configuration changes, we need to execute following terraform commands.

Now we can preview our changes before applying it to the infrastructure.

Now we can take a look at infrastructure changes that we are going to apply in the next step. Since we don’t have anything pre-configured, all 4 resources are going to be created.

This step plays a crucial part in the deployment process since we can catch any inconsistencies or unnecessary changes before they will be pushed to an actual organization.

Otherwise, we can place these variables into testing.auto.tfvar so they will be loaded automatically.

Be careful and never commit your token into any public repository.

Now we can go to the organization and see changes above applied:

The organization with one team, one repository, and one member

Team demo-team-1 with a user attached

Repository demo-repository with admin access for demo-team-1.

After making some changes, for example, downgrading demo-team-1 permissions to pull in demo-repository, we repeat plan and apply operations to update infrastructure.

Now new permission setting was applied to the repository.

As we can see Terraform provides a convenient way to store the whole Github organization configuration as a code. We can also version it and automate changes review and deployment with Jenkins and Github pull request hooks.

It’s easy to commit building infrastructure-as-a-code from scratch, but can we move existing Github organization to Terraform resources? The answer is yes!

To import existing resource into Terraform first we need to create appropriate resource declaration in our configuration.

The next step is to import resource to the Terraform state with import command, where the first argument is a name of the resource and the second one is repository name in the organization. After the import is done, we can check resource configuration from the state.

Here is a little bonus — a very useful article how to setup automated Git repositories backup with AWS S3 and Lambda.

No matter how many users, repositories and teams are in an organization. Terraform provides an easy way to define, organize and version all kind of resources and permissions for Github, as well as recreate organization structure from scratch any time.

All operations from creating new repositories to managing access rights can be automated with automated Jenkins pipeline and Github Pull Request, so there won’t be any need to do any of this manually anymore.

Add a comment

Related posts:

Interview with PR professional

I interviewed a PR professional who works in estates property company. Her name is Amy Ma. She is also one of my friend. Since it’s her third year, I think it might be something interesting happened…

It finally happened?

I just want to start off by saying that this is something I’ve thought about doing countless times but never had the guts to publish. The stories will be out of order in some cases, but as you join…

11 Things Men Secretly Adore in Women

All girls blush when they pass a guy they fancy, and it is a true fact! Women love to dress up for men in order to impress them but they often forget that it’s not in the eyes always. Men just not…