terraform-provider-aws: aws_codepipeline with Github OAuth still breaking auth
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave “+1” or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform CLI and Terraform AWS Provider Version
Terraform v0.12.28
+ provider.archive v1.3.0
+ provider.aws v3.0.0
+ provider.template v2.1.2
Affected Resource(s)
- aws_codepipeline
Terraform Configuration Files
resource "aws_codepipeline" "pipeline" {
name = "${var.ecs_service_name}-codepipeline"
role_arn = var.codepipeline_role
artifact_store {
location = var.artifact_store_bucket
type = "S3"
}
stage {
name = "Source"
action {
name = "SourceAction"
category = "Source"
owner = "ThirdParty"
provider = "GitHub"
version = "1"
output_artifacts = ["SourceArtifact"]
configuration = {
Owner = "XXXXXX"
Repo = var.repository_name
Branch = "main"
PollForSourceChanges = "true"
#OAuthToken = "*"
}
}
}
stage {
name = "Build"
action {
name = "Build"
category = "Build"
owner = "AWS"
provider = "CodeBuild"
version = "1"
input_artifacts = ["SourceArtifact"]
output_artifacts = ["BuildArtifact"]
configuration = {
ProjectName = "${var.ecs_service_name}-codebuild"
}
}
}
stage {
name = "Deploy"
dynamic action {
for_each = var.dedup_conf
content {
category = "Deploy"
configuration = {
ClusterName = var.ecs_cluster_name
ServiceName = "${var.ecs_service_name}-${action.key}"
FileName = "imagedefinitions.json"
}
input_artifacts = [
"BuildArtifact",
]
name = "${var.ecs_service_name}-${action.key}"
output_artifacts = []
owner = "AWS"
provider = "ECS"
run_order = 1
version = "1"
}
}
}
}
Debug Output
N/A
Panic Output
N/A
Expected Behavior
The existing OAuthToken should have been left in-place when the aws_codepipeline resource was updated.
Actual Behavior
Same behaviour as before, when you were forced to push a broken placeholder OAuthToken resource in order to update it. Only now you don’t have to comment-in the OAuthToken placeholder to update the resource.
Steps to Reproduce
terraform apply(after triggering authorizing to github, and forcing an update to theaws_codepipelineresource
Important Factoids
N/A
References
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 29
- Comments: 17 (4 by maintainers)
I’m experiencing this too.
On initial creation, source works fine. Change to resource and apply the update, now source is broken:
If I taint and recreate the pipeline, the source works again.
This absolutely remains a critical bug. There are significant permissions issues when using the CodeStar Connections approach with a GitHub Organization. The only way to provide discrete permission granularity without delegating your GitHub Organizations permissions to IAM is to use Personal Access Tokens, or some kind of nasty hack that pre-checks-out code with a Deploy Key and puts it into a bucket for the CodePipeline source stage to use, and the manual configuration requirement is also a problem.
Where this leaves us is the need to continue to use GitHub v1 connections in CodePipeline, and this is something we are addressing with our Technical Account Manager.
The problem we have is that any time we update a pipeline, we have to manually taint the pipeline so that it gets re-created because on every update the OAuth token is being broken.
Any support in getting this fixed so that we can continue to use this mechanism without breaking our pipelines would be fantastic.
Hello folks. I wanted to report a bug regarding this issue.
Below is a
TF_LOG=TRACEof me going through an exercise of creating a CodePipeline via Terraform and then making an update to it (changing a name of an action). In the process, I’m seeing that Terraform module is sending the literal"hash-<value>"as theOAuthTokenrequest parameter. Don’t worry about the GitHub token value in the logs that token was only used for this exercise and has since been deleted.Step 1: I’m creating a CodePipeline
It seems to do the correct thing and my CodePipeline is working well.
Step 2: Update the name of an action from “Approve” to “Approve2”
As you can see it’s sending the
"hash-<value>"literal as theOAuthTokenparameter. Here’s a check:Step 3: Run
terraform planI’m not sure what the correct fix would be but I wanted demonstrate that this is a bug and consequently when you configure a bogus token in AWS CodePipeline, the GitHub Source stage/action will not work. I look forward to what TF folks think. Thank you!
AWS CodeStarConnections now support Github: https://github.com/terraform-providers/terraform-provider-aws/issues/15453
Once you have a connection set up there you can use that as your source connection to bypass the entire OAuth song and dance:
Edit: According the the AWS Docs this old way of connecting to Github is deprecated and will be unsupported “soon” (not sure what that means).