Centralized IaC CircleCI Repository Strategies


#1

Hello! I have a quick question regarding how others use this tool. From what I can tell, Circle will always look for that specific config.yml (version 2) to tell it how to deploy whatever it is you’re doing; however, I want to achieve something that’s potentially a little different:

I want to centralize my IaC repository to include specific subdirectories for builds that we many want to execute. For example:

appName-build/
|──.circleci/
|       └─ config.yml
|──setup/
|       └─ setup.json (Cloudformation template for building the setup resources)
|──api/
|       └─ api.json (Cloudformation template for building resources related to api)
|──services/
|       └─ services.json (Cloudformation template for building lambdas + fargate)
|──images/
|       └─ script.sh (Script for pushing new image to ECR)

For just an image push, I may not want to rebuild the entire api format with cloudformation. How could I potentially pass a parameter to Circle to allow for a specific cloudformation template to be deployed?

Right now, we have multiple repositories for one app. Each repository contains the necessary build script for it to be built-- we’re triggering this manually by deploying the individual repositories. For scalability reasons, I want to segretate the IaC to only one repository.

appName-build-setup
|──.circleci/
|      |──config.yml
|      └─ aws_deploy.sh (Deploys builder.json to AWS)
|──builder.json (Cloudformation-specific template for setup)

appName-build-services
|──.circleci/
|      |──config.yml
|      └─ aws_deploy.sh (Deploys builder.json to AWS)
|──builder.json (Cloudformation-specific template for services)

...

appName-build-images
|──.circleci/
|      |──config.yml
|      └─ aws_deploy.sh (Deploys builder.json to AWS, no CF template for it)

To reiterate the question, how would I enforce CircleCI to only rebuild certain portions of the repository? Essentially, I want to be able to pass in a parameters such as --images or --services to only rebuild that specific folder. Does each folder need to contain a .circleci/? How would someone go about achieving the desired effect here?

Thanks!


#2

I figured out how to make this work. I discovered that CircleCI has something called an “API Trigger” that I could use to trigger a specific job in the config.yml. I will then use this feature to trigger certain jobs for the portions that I want to build.

Thank you!


#3

You can also use regexs on Git tags. This approach is popular to do deployments - without a tag is a regular build, and with a deploy-xxx tag is a build and deploy.


closed #4

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.