Working Around Terraform CodePipeline GitHub Authentication Errors
Overview
A GitHub authentication error occurred in a CodePipeline managed by Terraform, so this post summarizes how to work around it.
The following change was made in terraform-provider-aws v3.0.0, but it seems a different problem arises as a result.
resource/aws_codepipeline: Removes GITHUB_TOKEN environment variable (#14175)
How the Error Occurs
The Terraform code looks like this.
1 | resource "aws_codepipeline" "deploy" { |
GitHub authentication is performed via the configuration = {...} settings here.
On the first terraform apply, the value set for OAuthToken is stored in the tfstate file as a hash.
After that, when you update any resource, the hashed token in that tfstate is passed to UpdatePipeline, causing a GitHub authentication error.
So while GitHub authentication works fine in CodePipeline the first time, after running terraform apply and updating a resource, a GitHub authentication error occurs in CodePipeline.
This is discussed in the following issue.
Workaround
1 | resource "aws_codepipeline" "deploy" { |
By ignoring changes to the GitHub authentication so that CodePipeline’s authentication is not updated, I was able to work around the GitHub authentication error.
1 | lifecycle { |
The code I had used to deal with the problem of OAuthToken always showing up as a diff in terraform plan on earlier provider versions has come back around again.
I would appreciate hearing about any other ways to handle this.
That’s all.
I hope you find this helpful.
Working Around Terraform CodePipeline GitHub Authentication Errors
https://kenzo0107.github.io/en/2020/11/20/terraform-codepipeline-github-oauth-error/