0
votes

I currently have a terraform script that builds an AWS CodePipeline triggered by a GitHub webhook. It works fine, update to the repo triggers the build.

We also have a secondary repo with some content. Is it possible to have the same pipeline to be triggered by a webhook to that secondary repo? It should do exactly the same thing (pull the same source from the first repo and run the build) but triggered on the update to the secondary repo.

Terraform allows you to create the second webhook and attach it to the same pipeline, but the trigger doesn't seem to work.

1
One CodePipeline allows multiple source actions. A change to either source will cause an execution of the pipeline. The thing to remember is that each execution of pipelines will take out the latest source for both actions (not just the one with a change that caused the execution of the pipeline). The same should be programmable in Terraform.shariqmaws
like @shariqmaws said, its definitely possible using two sources. I am doing it currently (but with CDK). But keep in mind, that there wont be a merge in the buildmachine filesystem. The sources live in two different directories.Logemann

1 Answers

1
votes

Ok one way I found (like comments here suggested) is to hook secondary GitHub webhook to the CodePipeline webhook. It gets tricky though, I want pipeline to be triggered only for a specific branch match_equals = "refs/heads/{Branch}" so in order for this to work active branch name should be the same in both repos - not really realistic.

So I decided to go another way - a simple CodeBuild project is hooked to the second repo which, when triggered, just runs CLI aws codepipeline start-pipeline-execution on the main pipeline.