[#115624569] Workaround terraform codecommit issue with default_branch property #177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#115624569 Implement locking for pipelines
What?
We did not catch this issue in the PR #173.
Terraform codecommit resource[1] has a bug managing the default_branch
property: hashicorp/terraform#5641
Although this property is optional, terraform will try to manage it.
If defined, codecommit will fail during creation:
Meanwhile if default_branch is defined, codecommit it will fail as soon
as a branch is pushed to the repository. The reason is that AWS enforces
having at least one branch as default branch, failing when terraform is
trying to set it empty:
Scope
This issue will be reported upstream, but meanwhile we will workaround it by
passing the default branch as a variable, and quering it using awscli.
If the respository does not exist or does not have default branch, the
variable will be set to empty string "".
We additionally remove the bump of the
pipeline-trigger
in the init job, which is not required anymore.How to test
Running from a environment without an associated codecommit git pool-resource
respository:
SELF_UPDATE_PIPELINE=false BRANCH=$(git rev-parse --abbrev-ref HEAD) make dev bootstrap DEPLOY_ENV=...
concourse-terraform
(the rest are not relevant)concourse-terraform
should finnish OKterraform apply
output for the resourceaws_codecommit_repository.concourse-pool
should not refer to anydefault_branch
concourse-terraform
it should end OK.lock-pipeline
job increate-bosh-cloudfoundry
a. Upload the pipelines:
SELF_UPDATE_PIPELINE=false BRANCH=$(git rev-parse --abbrev-ref HEAD) make dev pipelines DEPLOY_ENV=...
b. This will create a initial branch in the codecommit repo.
concourse-terraform
Who?
Anyone but @keymon