How to deploy several codeBuild projects with CloudFormation in CodePipeline

917 Views Asked by At

In order to have clarity on my codePipeline steps, I decided to have several codeBuild projects with different build spec files.

I'm facing an issue to specify for each codeBuild project which build spec file to use. When defining the cloudformation template to deploy the codeBuild project, the Source property of AWS::CodeBuild::Project needs to be set on CODEPIPELINE; so I'm not sure where I can specify the different paths.

Currently, my structure is as such:

  • codepipeline file
    • Deploy step 1.1 > deploys a cloudformation template in which a codebuild project is defined
    • Build step 1.2 > launches the codebuild project
    • ... > some other steps that uses previously deployed stuff
    • Deploy step 2.1 > deploys another cloudformation template in which a different codebuild project is definied
    • Build step 2.2 > launches the newly defined codebuild project
  • cloudFormation file with the first codebuild project
  • cloudFormation file with the second codebuild project
  • buildspec 1
  • buildspec 2

Any idea where to define the paths?

Many thanks in advance, Joel

1

There are 1 best solutions below

0
On BEST ANSWER

The solution is actually to define the BuildSpec property inside of the Source object (see below). I didn't think it was possible as I thought by mentioning code pipeline as a source, we couldn't give any other detail.

So, in your cloudformation template defining the AWS::CodeBuild::Project, just add the name of build spec file to use, in addition to the code pipeline source type:

Source:
  Type: CODEPIPELINE
   BuildSpec: "my_custom_filename.yml"