Documentation enhancements for github_repository_deployment_branch_policy
resource
#1820
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.
Before the change?
The documentation example is missing the required
depends_on
meta-argument. Without this, Terraform will often try to deploy thegithub_repository_deployment_branch_policy
before the correspondinggithub_repository_environment
which results in an ambiguous 404 error being returned from the API.A separate (but equally ambiguous) 404 is returned from the API when the
github_repository_environment
referenced by thegithub_repository_deployment_branch_policy
resource hascustom_branch_policies
set tofalse
. I believe the design pattern is to catch this error in the Terraform provider rather than rely on the API returning a descriptive error (which it doesn't do). This can catch one off-guard since the documentation says thecustom_branch_policies
must be set totrue
, but doesn't mention the somewhat unusual behaviour of the API returning a 404 (rather than Terraform complaining about the attribute) if this attribute is set incorrectly. This personally caused me a few hours of frustration, so it would be good to make others aware of this behaviour.The Terraform code in the example hadn't been run through
terraform fmt
.After the change?
The required
depends_on
attribute has been added to the documentation example to prevent the branch policy being created before the corresponding environment.The
environment_name
argument's description has been enhanced to describe the behaviour that occurs ifdeployment_branch_policy.custom_branch_policies
is not set totrue
.The examples have been run through
terraform fmt
.Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!