Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export existing CodePipeline/CodeBuild projects to Cloudformation

Is there a way to export existing CodePipeline/CodeBuild projects to Cloudformation?

I'm in the process of converting our existing CI/CD infrastructure into code so it would be easy to replicate them on other AWS regions.

Currently, we've done all our CodePipeline/CodeBuild projects through the AWS console in the browser and obviously, this is tedious and error-prone.

like image 358
Noel Llevares Avatar asked Dec 20 '17 00:12

Noel Llevares


People also ask

How do you generate a CloudFormation from an existing resource?

Create a stack from existing resources using the AWS Management Console. Sign in to the AWS Management Console and open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation . On the Stacks page, choose Create stack, and then choose With existing resources (import resources).

What is the difference between CodeBuild and CodePipeline?

CodePipeline builds, tests, and deploys your code every time there is a code change, based on the release process models you define. AWS CodeBuild can be classified as a tool in the "Continuous Integration" category, while AWS CodePipeline is grouped under "Continuous Deployment".


1 Answers

If you have some codepipeline already created use the cli to extract them as cloudformation.

The command is roughly this

aws codepipeline get-pipeline --name

It will get you back a codepipeline resource for cloudformation. You will be able to see where you need to enter in other resources like codebuild projects and s3 buckets or codecommit repos.

Be aware though that you will need to work through the template to ensure it will be taken as valid by cloudformation. The lines of the resource from the cli need to start with capital letters so it can be tedious to change that.

Another thing to know is a pipeline needed I think two roles which you can have in your template also and it's own bucket. All of these things cab be put in a single template making reproducible pipelines possible. Good luck!

like image 91
hynespm Avatar answered Sep 21 '22 16:09

hynespm