I have a Terrafrom GitHub repository. It is set up like this
/globals is my base setup to setup the GCP folders and projects
/network/non-prod is for the VPC for the development infrastructure
/network/staging is for the VPC for the staging infrastructure
/network/prod is for the VPC for the production infrastructure
/logging/[non-prod, staging, prod] for logging
/monitoring/non-prod, staging, prod] for monitoring
. . . and a lot more
Each directory is an independent terraform build and has its own state file.
I am trying to use the path-filtering-orb here is my configuration:
version: 2.1 setup: true orbs: path-filtering: email@example.com workflows: always-run: jobs: - path-filtering/filter: name: check-updated-files base-revision: main config-path: .circleci/continue.yml mapping: | global.* run-global-job true network/non-prod/.* run-network-non-prod-job true network/prod/.* run-network-prod-job true network/staging/.* run-network-staging-job true modules/gcp-project
In my continuation config I have a job that builds terraform it uses
firstname.lastname@example.org to do it’s build. Here is the job that builds Terraform:
workflows: terraform-global: when: << pipeline.parameters.run-global-job >> jobs: - set-gcp-credentials - validate-gcp-credentials - terraform-lint - terraform-validate: requires: - terraform-lint - set-gcp-credentials - validate-gcp-credentials context: - Terraform terraform-network-nonprod: when: << pipeline.parameters.run-network-non-prod-job >> jobs: - set-gcp-credentials - validate-gcp-credentials - terraform-lint - terraform-validate: requires: - terraform-lint - set-gcp-credentials - validate-gcp-credentials context: - Terraform
I don’t want to duplicate the terraform-validate job for each individual piece of infrastructure.
What I want to do is to be able to pass in the directory that the terraform files are located and then run terraform on the files in that directory. If terraform files change in multiple directories then I want to process all of the files that changed.
I have only been using CircleCi for a month. We just switched from Jenkins and this was easy to do in Jenkins. I assume it is just my lack of knowledge or CircleCi.
Thanks for your help.