Skip to content

Fix terraform-drift: use make bootstrap not nonexistent bootstrap-ci#42

Merged
infrahouse8 merged 1 commit into
mainfrom
fix-drift-bootstrap-target
Jul 4, 2026
Merged

Fix terraform-drift: use make bootstrap not nonexistent bootstrap-ci#42
infrahouse8 merged 1 commit into
mainfrom
fix-drift-bootstrap-target

Conversation

@akuzminsky

Copy link
Copy Markdown
Member

Bug

After the role-extraction fix, the drift sweep now gets past AWS auth and fails at Setup Python Environment:

make: *** No rule to make target 'bootstrap-ci'.  Stop.

(example run)

The step runs make bootstrap-ci in environments/<env>/, but the shared makefile.mk only defines bootstrap (pip install -r requirements.txt). terraform-CI.yml / terraform-CD.yml already call make bootstrap.

Fix

Change the drift workflow's Setup step to make bootstrap, matching CI/CD and the actual target.

Remaining known issues in this workflow (not in this PR)

Flagging these so they're tracked — happy to fix in a follow-up:

  1. check_drift never sets its exitcode output. The step runs terraform plan -detailed-exitcode but writes no exitcode output, and the default bash -e shell aborts on exit code 2 (changes present). So on actual drift the job fails and the if: steps.check_drift.outputs.exitcode == 2 steps (record entry / create PR) never run.
  2. Create Pull Request uses steps.app-token.outputs.token, but no app-token step exists in the workflow.

🤖 Generated with Claude Code

…trap-ci`

The drift job ran `make bootstrap-ci` in environments/<env>/, but the shared
makefile.mk only defines `bootstrap` (pip install -r requirements.txt) — so the
step failed with "No rule to make target 'bootstrap-ci'". terraform-CI/CD
already use `make bootstrap`; align the drift workflow with them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@infrahouse8 infrahouse8 enabled auto-merge July 4, 2026 23:19
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

State s3://infrahouse-github-control-state/terraform.tfstate

Affected resources counts

Success Add 🟡 Change Destroy
0 1 0

Affected resources by action

Action Resources
🟡 module.aws_service_infrahouse_app.github_repository_file.terraform_drift[0]
STDOUT
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.aws_service_infrahouse_app.github_repository_file.terraform_drift[0] will be updated in-place
  ~ resource "github_repository_file" "terraform_drift" {
      ~ content             = <<-EOT
            ---
            name: "Terraform Drift Detection"
            
            on:  # yamllint disable-line rule:truthy
              workflow_call:
                inputs:
                  env:
                    type: "string"
                    required: true
            
            permissions:
              id-token: "write"  # This is required for requesting the JWT
              contents: "write"
              pull-requests: "write"
              issues: "write"  # Required to create and apply labels
            
            concurrency:
              group: "terraform-drift-${{ inputs.env }}"
              cancel-in-progress: false
            
            jobs:
              terraform-drift:
                name: "Terraform Drift Detection"
                runs-on: ubuntu-24.04
                environment: "continuous-integration-${{ inputs.env }}"
                timeout-minutes: 15
                env:
                  GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
                  REGION_JSON: "${{ vars.AWS_DEFAULT_REGION }}"
                  ROLE_GITHUB_JSON: "${{ vars.ROLE_GITHUB }}"
            
                defaults:
                  run:
                    shell: "bash"
                    working-directory: "environments/${{ inputs.env }}"
            
                steps:
                  - name: "Checkout"
                    uses: "actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10"  # v6
            
                  - name: "Extract Variables"
                    id: "extract_vars"
                    env:
                      REGION_JSON_CONTENT: ${{ env.REGION_JSON }}
                      ROLE_GITHUB_JSON_CONTENT: ${{ env.ROLE_GITHUB_JSON }}
                      TARGET_ENV: ${{ inputs.env }}
                    run: |
                      REGION=$(echo "$REGION_JSON_CONTENT" | jq -r ".${TARGET_ENV}")
                      echo "REGION=$REGION" >> "$GITHUB_OUTPUT"
                      ROLE_GITHUB=$(echo "$ROLE_GITHUB_JSON_CONTENT" | jq -r ".${TARGET_ENV}")
                      echo "ROLE_GITHUB=$ROLE_GITHUB" >> "$GITHUB_OUTPUT"
            
                  - name: "Configure AWS Credentials"
                    uses: "aws-actions/configure-aws-credentials@254c19bd240aabef8777f48595e9d2d7b972184b"  # v6
                    with:
                      role-to-assume: "${{ steps.extract_vars.outputs.ROLE_GITHUB }}"
                      role-session-name: "github-actions-${{ inputs.env }}"
                      aws-region: "${{ steps.extract_vars.outputs.REGION }}"
            
                  - name: "Set Terraform version"
                    id: "terraform_version"
                    run: |
                      echo "IH_TF_VERSION=$(cat .terraform-version)" >> "$GITHUB_OUTPUT"
            
                  - name: "Setup Terraform"
                    uses: "hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e"  # v4
                    with:
                      terraform_version: "${{ steps.terraform_version.outputs.IH_TF_VERSION }}"
            
                  - name: "Set up Python"
                    uses: "actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1"  # v6
                    with:
                      python-version: "3.14"
            
                  - name: "Setup Python Environment"
                    run: |
          -           make bootstrap-ci
          +           make bootstrap
            
                  - name: "Terraform Init"
                    run: |
                      terraform init -input=false
            
                  - name: "Check if any changes are planned"
                    id: "check_drift"
                    run: |
                      terraform plan -no-color -input=false -detailed-exitcode
            
                  - name: Cleanup working dir
                    run: git clean -df
            
                  - name: "Record Config Drift Log Entry"
                    if: "steps.check_drift.outputs.exitcode == 2"
                    run: |
                      git \
                      -c user.name="${{ github.actor }}" \
                      -c user.email="${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" \
                      commit -m "Reconcile configuration drift" --allow-empty
            
                  - name: "Check for open PR with label"
                    id: "check_label"
                    if: "steps.check_drift.outputs.exitcode == 2"
                    run: |
                      LABEL="config-drift"
                      REPO="${{ github.repository }}"
                      COUNT=$(gh pr list --repo "$REPO" --label "$LABEL" --state open --json number --jq 'length')
                      echo "Found $COUNT open PR(s) with label '$LABEL'"
                      if [[ $COUNT -gt 0 ]]; then
                        echo "label_exists=true" >> $GITHUB_OUTPUT
                      else
                        echo "label_exists=false" >> $GITHUB_OUTPUT
                      fi
            
                  - name: "Create Pull Request"
                    if: "steps.check_label.outputs.label_exists == 'false'"
                    uses: "peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1"  # v8
                    with:
                      token: "${{ steps.app-token.outputs.token }}"
                      base: "main"
                      branch: "create-pull-request/config-drift"
                      title: "[config-drift] Reconcile Terraform configuration drift in ${{ inputs.env }}"
                      commit-message: "[config-drift] Configuration drift record for ${{ inputs.env }}"
                      team-reviewers: "devops-members"
                      labels: |
                        config-drift
        EOT
        id                  = "aws-service-infrahouse-app:.github/workflows/terraform-drift.yml:main"
        # (9 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Warning: Argument is deprecated

  with module.ih_8_repos.github_repository.repo,
  on modules/local-repo/repos.tf line 4, in resource "github_repository" "repo":
   4:   has_downloads        = false

This attribute is no longer in use, but it hasn't been removed yet. It will
be removed in a future version. See
https://github.com/orgs/community/discussions/102145#discussioncomment-8351756

(and 6 more similar warnings elsewhere)

Warning: Deprecated attribute

  on .terraform/modules/actions-runner-pem-493370826424-uw1/data_sources.tf line 11, in data "external" "secret_value":
  11:     "python", "${path.module}/assets/get_secret.py", data.aws_region.current.name, aws_secretsmanager_secret.secret.id, data.aws_iam_role.caller_role.arn

The attribute "name" is deprecated. Refer to the provider documentation for
details.

(and 5 more similar warnings elsewhere)

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: tf.plan

To perform exactly these actions, run the following command to apply:
    terraform apply "tf.plan"
metadata
eyJzMzovL2luZnJhaG91c2UtZ2l0aHViLWNvbnRyb2wtc3RhdGUvdGVycmFmb3JtLnRmc3RhdGUiOiB7InN1Y2Nlc3MiOiB0cnVlLCAiYWRkIjogMCwgImNoYW5nZSI6IDEsICJkZXN0cm95IjogMH19

@infrahouse8 infrahouse8 merged commit e34283b into main Jul 4, 2026
2 checks passed
@infrahouse8 infrahouse8 deleted the fix-drift-bootstrap-target branch July 4, 2026 23:25
@infrahouse8 infrahouse8 deployed to production July 4, 2026 23:25 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants