'Github Actions run terraform init in multiple directories
I have 3 Terraform directories:
test_1
test_2
test_3
I would like to run terraform init in each of these directories. Is there a way to do this with a loop instead of specifying it 3 individual times?
I have the below code that runs it once inside only test_1 directory.
defaults:
run:
working-directory: test_1
jobs:
terraform-plan:
name: "Terraform"
runs-on: ubuntu-latest
steps:
- name: "Run - Terraform Init"
run: terraform init
Solution 1:[1]
Here's an idea.
defaults:
run:
working-directory: root_dir
jobs:
terraform-plan:
name: Terraform
runs-on: ubuntu-latest
steps:
- name: Run - Terraform Init
run: |
find -mindepth 1 -maxdepth 1 -type d -exec terraform init \;
Keep in mind this needs to be done in parent dir of those test dirs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | frennky |
