Deploying a single module with Circle CI

modules
terragrunt
#1

Hello!

We have a couple of teams starting to use Terragrunt. One using terragrunt-all and another trying to deploy modules individually. We also use Circle CI, seems like Terragrunt is using CCI internally as well. Curious if there is a pattern where folks are deploying a single module out of the “live” repo with Circle Ci. The mental hangup at the moment is there is 1 .circleci/config.yaml per repo. Seems like there is a way to use the CCI API to call a specific job, that’s the only thing we’ve come across so far that might help. Thoughts?

#2

Just to make sure I understand, is your question how to know in which module to run Terraform or Terragrunt? For example, if you have a repo with:

├ .circleci
│ └ config.yaml
├ app
│ └ main.tf
├ mysql
│ └ main.tf
└ vpc
  └ main.tf

And if a commit is made, you don’t know in which folder to run apply?

#3

Hi. That part is understood, given your project structure, deploying a single module would be as easy as changing your current working dir to one containing a .tfvars and running Terragrunt commands from there. Which works great.

The question is how to do the above and terragrunt-all out of one .circleci/config. Trying to think of the least hacky way to do so. Probably some env vars and a conditional.

Does that make anything more clear?

#4

No, sorry, I’m feeling a bit dense today, and still not following what you’re trying to solve :slight_smile:

Could you provide an example of your workflow, what you’d want it to be like, and where you’re getting stuck with making that happen with CircleCI?

#5

Apologies, I’m speaking generally instead of concretely. I’m going to play a bit using the following.
https://circleci.com/docs/2.0/api-job-trigger/#conditionally-running-jobs-with-the-api

I should be able to communicate better from there :slightly_smiling_face: