Skip to content

IaC & CI/CD: Logs

IaC & CI/CD commands for logs (tags: #logs #cloudwatch).

Index
4 items

Terraform1

Terraform: Enable debug logging

Safe

Write provider/API level debug logs to a file.

TF_LOG=DEBUG TF_LOG_PATH=./tf-debug.log terraform plan
What each part does
  1. TF_LOG=DEBUGlog level for this run: TRACE, DEBUG, INFO, WARN, ERROR
  2. TF_LOG_PATH=./tf-debug.logwrite the log to a file instead of stderr
  3. terraform planthe command to debug

Also known as: TF_LOG · tf debug

GitHub Actions1

GitHub Actions: Show logs of failed steps

Safe

Only the log output of failed steps. gh run list shows recent run ids.

gh run view <run-id> --log-failed
What each part does
  1. gh run view <run-id>show a workflow run (gh run list gives the IDs)
  2. --log-failedprint only the logs of the failed steps

Also known as: gha logs · workflow failed · gh run view

GitLab CI1

GitLab CI: Show a job's log

Safe

Stream the log of a CI job (pick interactively if you omit the id).

glab ci trace <job-id>
What each part does
  1. glab ci tracestream a CI job's log (follows it while running)
  2. <job-id>the job ID; leave it out to pick a job interactively

Also known as: job log · glab trace

Jenkins1

Jenkins: Tail a build's console log

Safe

Last 100 lines of the latest build's console without opening the UI.

curl -sS -u <user>:<api-token> "<jenkins-url>/job/<job>/lastBuild/consoleText" | tail -n 100
What each part does
  1. curl -sSquiet, but still show errors
  2. -u <user>:<api-token>basic auth with a Jenkins API token
  3. /job/<job>/lastBuild/consoleTextplain-text console output of the latest build (use a build number instead of lastBuild)
  4. | tail -n 100only the last 100 lines

Also known as: jenkins console · build log

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…