Slide 2 of 8

CI/CD pipeline architecture

CI/CD pipeline flow

This diagram shows the end-to-end pipeline from code commit to deployed resources.

Diagram showing CI/CD pipeline: on pull request, HCL code flows through Terraform plan and PR comment stages; on merge to main, it continues through Terraform apply to live resources in Grafana

What each stage does

The pipeline has two stages, each triggered at a different point in the workflow.

StageTriggerAction
PlanEvery pushShow what Terraform will change
ApplyMerge to main onlyDeploy changes to Grafana

When each path runs

The same stages run along two paths, depending on where the code is in the workflow:

  • On a pull request: the pipeline runs plan, then posts the plan as a PR comment for review. Nothing is deployed yet.
  • On merge to main: the pipeline runs plan and apply. Terraform applies the changes, so the resources in Grafana always reflect the latest code on main.

The review gate

The Terraform plan output is posted as a PR comment so you can see:

  • Which resources will be created, updated, or destroyed
  • Exactly what configuration will change

This gives you the full benefits of resources as code: every change is reviewed, every deployment is automated, and you can trace any resource back to the commit that produced it.

Script

The pipeline has two stages. First, plan: Terraform reads your HCL files and shows what will change. Second, apply: on merge to main, Terraform deploys the changes to Grafana.

On pull requests, the pipeline runs plan only. It posts the Terraform plan as a PR comment so reviewers can see exactly what will change in Grafana before approving. This is your review gate, the same pattern you use for infrastructure changes.

On merge to main, the pipeline runs both stages. Terraform plans and then applies the changes to your Grafana instance. The resources in Grafana always reflect the latest code on main.

This pipeline is simpler than the dashboards-as-code pipeline because there’s no generate step. Your resources are already defined in HCL, so the pipeline goes straight to plan and apply.