diggerhq / digger

Digger is an open source IaC orchestration tool. Digger allows you to run IaC in your existing CI pipeline ⚡️
https://digger.dev
Apache License 2.0
2.88k stars 139 forks source link

Supporting generation of projects for terragrunt workspaces #424

Open motatoes opened 1 year ago

motatoes commented 1 year ago

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

nilsdebruin commented 1 year ago

Great!

motatoes commented 1 year ago

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!

Nilsas commented 11 months ago

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/digger@v0.1.27
        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

motatoes commented 11 months ago

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 !

zMynxx commented 6 months ago

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