digger icon indicating copy to clipboard operation
digger copied to clipboard

Supporting generation of projects for terragrunt workspaces

Open motatoes opened this issue 1 year ago • 5 comments

We currently support generating projects dynamically for terraform projects using the toplevel generate_projects pattern https://docs.digger.dev/configuration/digger.yml#top-level

We would like to support the same for terragrunt projects This can be done similar to [1] but traversing for terragrunt.hcl files and analysing dependencies for building the dependency graph

[1] https://github.com/transcend-io/terragrunt-atlantis-config

motatoes avatar Jul 05 '23 09:07 motatoes

Great!

nilsdebruin avatar Jul 05 '23 10:07 nilsdebruin

Hi @nilsdebruin this is now supported and here are the docs page for it: https://docs.digger.dev/configuration/terragrunt-project-generation

Please give it a shot and let us know if that addresses it for you!

motatoes avatar Sep 01 '23 17:09 motatoes

Hey Guys, just found this issue, I'm trying to setup terragrunt, but generate projects does not seem to be working, my digger.yml

generate_projects:
  terragrunt_parsing:
    parallel: true
    createProjectName: true
    createWorkspace: true
    defaultWorkflow: default

workflows:
  default:
    plan:
      steps:
        - init
        - plan
    apply:
      steps:
      - init
      - apply:
        extra_args: ["-compact-warnings"]
    workflow_configuration:
      on_pull_request_pushed: ["digger plan"]
      on_pull_request_closed: ["digger unlock"]
      on_commit_to_default: ["digger apply"]

github actions pipeline

name: CI

on:
  pull_request:
    branches: 
      - "master"
    types: 
      - closed 
      - opened
      - synchronize
      - reopened
  issue_comment:
    types: 
      - created
    if: contains(github.event.comment.body, 'digger')
  workflow_dispatch:

jobs:
  build:
    runs-on: self-hosted
    permissions:
      id-token: write
      contents: read
      issues: write
      pull-requests: write

    steps:
      - uses: actions/checkout@v3

      - name: Checkout Pull Request
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          PR_URL="${{ github.event.issue.pull_request.url }}"
          PR_NUM=${PR_URL##*/}
          echo "Checking out from PR #$PR_NUM based on URL: $PR_URL"
          hub pr checkout $PR_NUM
        if: github.event_name == 'issue_comment'

      - name: digger run
        uses: diggerhq/[email protected]
        with:
          setup-google-cloud: true # FOR aws use setup-aws instead
          google-auth-credentials: '${{ secrets.GCP_CREDENTIALS }}'
          setup-terragrunt: true
          terragrunt-version: 0.45.0
        env:
          LOCK_PROVIDER: gcp
          GITHUB_CONTEXT: ${{ toJson(github) }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GOOGLE_STORAGE_BUCKET: digger_bucket

I am seeing this in the logs

 2023/10/21 05:34:18 Using GCP lock provider.
Lock provider has been created successfully
Using GitHub.
GitHub context parsed successfully
Digger config read successfully
2023/10/21 05:34:18 Using GCP lock provider.
Lock provider has been created successfully
2023/10/21 05:34:19 Following projects are impacted by pull request #2
No projects impacted
GitHub event processed successfully

Obviously my PR has relevant changes to the terragrunt.hcl files. I have setup Atlantis and terragrunt-atlantis-config on the same repository it manages to plan the changes. What am I doing wrong here? @motatoes

Nilsas avatar Oct 21 '23 05:10 Nilsas

hey @Nilsas I'm not spotting anything there, likely some bug, it would be helpful if you can share with me a repo to help me debug the issue !

motatoes avatar Oct 21 '23 16:10 motatoes

have you figured how to run digger destroy <project> when using the auto-generator?

zMynxx avatar Mar 28 '24 16:03 zMynxx