Open kmanning opened 3 years ago
The way my team works with infrastructure-as-code and peer review, we have a number of "rules". Among them:
master
branch in the repo should, at all times, match the state of the running infrastructure.master
branch.This all works fine if everyone is sharing the same repository and working on branches, but it becomes problematic if people fork the repo. Specifically, let's take the following scenario:
So, that becomes a bit of an issue in a few (admittedly maybe edge) cases:
ConfirmApplyPlugin
configured, as my un-reviewed code can affect real infrastructure.I'm going to focus on the example above for this particular posting. I'm saying this to acknowledge that there might be other UseCases that should also be discussed as part of this Issue, but in a separate post.
To reiterate the assumptions, to ensure that I understand the problem correctly:
In the situations in which you're having problems, the above problem descriptions seem to suggests some corollary statements:
If the above 2 corollary statements are true, then preventing changes outside of the origin/master branch doesn't seem possible, and in fact, seems outside the scope of terraform-pipeline.
One question: What's your workflow for your fork with in your Git Org Folder? I also use forks in a similar fashion, but I don't have a Git Org Folder in Jenkins to build my forks. I rely on my change being built locally as I code, and then being verified when I open my PR against the origin project. To rephrase the question - what builds are you expecting in your GitHub Org Folder containing your fork, that motivated you to make a Github Org Folder for your fork?
That said, let's step back a bit, and let's ignore the statement that this problem, "seems outside the scope of terraform-pipeline". If I wanted to put myself in your shoes, and wanted to solve the problem anyhow, I think I'd attack the two corollary statements.
Your fork Github Org Folder has access/permission to the same resources. <-- Is there a way to solve this problem outside of terraform-pipeline?
Your fork has access to the same shared state, AND the configuration for that state is hardcoded in your source code. <-- I'm making a number of assumptions here, based on the symptoms of your problem. By default, terraform state is a local file. That would mean that a fork does not have access to that local file in the origin/master repo. That leads me to believe that your state is remote, and that the configuration to that remote state is hardcoded in your terraform code. Are those assumptions true? If so, I would approach the problem by separating your code and state configuration. Once the state configuration is separated, the fork would no longer have access to the state. Would that solve your problem? This notion is in fact built into some of the Backend Plugins (Eg: S3BackendPlugin - which uses the Git Org to construct the path to the S3 state file. Which means if you fork, the fork gets its own state, which potentially solves your problem.)