0

In my use-case I have one dir with 2 file,where are I am calling two atlanis workflow when there is change is files.But I am getting the following error

parsing atlantis.yaml: there are two or more projects with dir: "/dirabc " workspace: "default" that are not all named; they must have a 'name' key so they can be targeted for apply's separately

atlantis.yaml look like below

version: 2

projects:

- dir: /dirabc
  workflow: terragrunt-workflow-file1
  apply_requirements: [approved]
  autoplan:
    when_modified: ["file1.tf"]
    enabled: true
- dir: /dirabc
  workflow: terragrunt-workflow-file2
  apply_requirements: [approved]
  autoplan:
    when_modified: ["file2.tf"]
    enabled: true

workflows:
  terragrunt-workflow-aurora-file1:
    plan:
      steps:
        - run: rm -rf .terraform
        - run: terragrunt plan -no-color --terragrunt-non-interactive --target module.file1
    apply:
      steps:
        - run: terragrunt apply -no-color --terragrunt-non-interactive -auto-approve --target module.file1
  terragrunt-workflow-aurora-file2:
    plan:
      steps:
        - run: rm -rf .terraform
        - run: terragrunt plan -no-color --terragrunt-non-interactive --target module.file2
    apply:
      steps:
        - run: terragrunt apply -no-color --terragrunt-non-interactive -auto-approve --target module.file2

How we run the multiple workflow in same dir on different file change. Also I removed the step 'rm -rf .terrafrom' still getting the same error on 'atlantis plan'

Khushboo Kumari
  • 145
  • 1
  • 14

1 Answers1

0

We can add the name when the dir is same, like:

version: 2

projects:

- dir: /dirabc
  name: file1
  workflow: terragrunt-workflow-file1
  apply_requirements: [approved]
  autoplan:
    when_modified: ["file1.tf"]
    enabled: true
- dir: /dirabc
  name: file2
  workflow: terragrunt-workflow-file2
  apply_requirements: [approved]
  autoplan:
    when_modified: ["file2.tf"]
    enabled: true

workflows:
  terragrunt-workflow-aurora-file1:
    plan:
      steps:
        - run: terragrunt plan -no-color --terragrunt-non-interactive --target module.file1
    apply:
      steps:
        - run: terragrunt apply -no-color --terragrunt-non-interactive -auto-approve --target module.file1
  terragrunt-workflow-aurora-file2:
    plan:
      steps:
        - run: terragrunt plan -no-color --terragrunt-non-interactive --target module.file2
    apply:
      steps:
        - run: terragrunt apply -no-color --terragrunt-non-interactive -auto-approve --target module.file2
``
Khushboo Kumari
  • 145
  • 1
  • 14