diff --git a/.github/workflows/terraform-terragrunt.yml b/.github/workflows/terraform-terragrunt.yml index b31e303..9c860a1 100644 --- a/.github/workflows/terraform-terragrunt.yml +++ b/.github/workflows/terraform-terragrunt.yml @@ -11,6 +11,9 @@ on: jobs: terraform: runs-on: ubuntu-latest + env: + GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }} + GITLAB_ACCESS_TOKEN: ${{ secrets.GITLAB_ACCESS_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -30,19 +33,17 @@ jobs: BRANCH_CONFIG=$(jq -r --arg branch "$BRANCH_NAME" '.branches[$branch] // .branches.default' $CONFIG_FILE) TF_WORKSPACE=$(echo $BRANCH_CONFIG | jq -r '.TF_WORKSPACE') TG_WORKDIR=$(echo $BRANCH_CONFIG | jq -r '.TG_WORKDIR') - - echo "TF_WORKSPACE=$TF_WORKSPACE" >> $GITHUB_ENV echo "TG_WORKDIR=$TG_WORKDIR" >> $GITHUB_ENV echo "TF_VERSION=$TF_VERSION" >> $GITHUB_ENV echo "TG_VERSION=$TG_VERSION" >> $GITHUB_ENV + echo "THE_TF_WORKSPACE=$TF_WORKSPACE" >> $GITHUB_ENV - name: Set up Terraform CLI uses: hashicorp/setup-terraform@v3 with: terraform_version: ${{ env.TF_VERSION }} terraform_wrapper: true - cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} - + - name: Set up Terragrunt CLI run: | wget -qO /tmp/terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v${{ env.TG_VERSION }}/terragrunt_linux_amd64 @@ -70,4 +71,4 @@ jobs: - name: Display success message if: github.event_name == 'workflow_dispatch' run: | - echo "🚀 Terraform Terragrunt Action triggered manually!" + echo "🚀 Terraform Terragrunt Action triggered manually!" \ No newline at end of file diff --git a/config.json b/config.json index 92c8629..64547ed 100644 --- a/config.json +++ b/config.json @@ -13,6 +13,10 @@ "dev": { "TF_WORKSPACE": "dev-project", "TG_WORKDIR": "environment/dev" + }, + "gitlab-state": { + "TF_WORKSPACE": "prod-project", + "TG_WORKDIR": "environment/stage" } } } diff --git a/terragrunt.hcl b/terragrunt.hcl index 747b913..6ecdc69 100644 --- a/terragrunt.hcl +++ b/terragrunt.hcl @@ -1,27 +1,23 @@ # Define the Terraform backend configuration to use Terraform Cloud locals { - organization = "kintaro" - workspace_tags = "kintaro_devops" + project_id = "61383408" } - generate "backend" { path = "auto_generated_backend.tf" if_exists = "overwrite" contents = <