Cloud platforms · AWS and Azure

CI/CD and infrastructure as code with GitHub Actions, Terraform, ECR and ECS blue/green

A delivery pipeline with no long-lived credentials: pull requests plan, merges apply, images are scanned, signed and shipped with an SBOM, and releases shift traffic gradually with automatic rollback.

A reference architecture from EITSAA, not a named client system. Service limits, prices and product features change, so confirm current details before you commit to a design.

  • ASD Essential Eight
  • SACSF and ACSC ISM alignment
  • NIST SSDF (SP 800-218)
  • OWASP Top 10:2025 (A03 supply chain)

Architecture

Architecture diagram. Tinted boundaries show regions, accounts, networks and trust zones. Numbered arrows match the flow below.
CI/CD and infrastructure as code with GitHub Actions, Terraform, ECR and ECS blue/green architectureDeveloper to Repository: PR. Repository to GitHub Actions: trigger. GitHub Actions to Scan and test: gates. GitHub Actions to Amazon ECR: push image. GitHub Actions to Terraform: plan / apply. Terraform to S3 state + lockfile: state. Amazon ECR to ECS deployment: image. ECS deployment to ECS service: shift traffic. CloudWatch alarms to ECS deployment: rollbackGitHubAWS accounts (tooling, non-prod, prod)DeveloperPull requestRepositoryBranch protection, CODEOWNERSGitHub ActionsOIDC, environmentsScan and testSAST, SCA, secrets, IaC, SBOMAmazon ECRImmutable tags, scan on pushTerraformPlan on PR, apply on mergeS3 state + lockfileVersioned, KMSECS deploymentBlue/green, canary, hooksECS serviceBlue and green target groupsCloudWatch alarmsTrigger rollback1PR2trigger3gates4push image5plan / applystate6image7shift traffic8rollbackPlatform servicesAWS IAMAmazonCloudWatchAWS CloudTrailAWS KMS
  • People and clients
  • Delivery tooling
  • AI and ML
  • Compute and containers
  • Object and file storage
  • Monitoring, audit and analytics
  • Security and identity
  • Request or data flow
  • Asynchronous or optional
  • Boundary: region, account, network or trust zone

Request and data flow

  1. A developer opens a pull request. Branch protection requires review, status checks and signed commits for protected branches.

  2. The workflow starts and requests an OIDC token from GitHub. AWS trusts only this repository, branch or environment through the IAM role trust policy.

  3. Unit tests, static analysis, dependency and secret scanning, and IaC policy checks (for example Checkov, Trivy or OPA) run as gates, and the build generates an SBOM in CycloneDX or SPDX format.

  4. A successful build pushes an image tagged with the commit SHA to ECR, signs it and records a build provenance attestation. Scan on push findings above the agreed threshold fail the release.

  5. Terraform plans on the pull request and posts the plan. On merge to main it applies in non-production, then production after an environment approval.

  6. The Amazon ECS built-in blue/green deployment (or CodeDeploy in existing pipelines) starts the new service revision as green behind the load balancer, and a Lambda lifecycle hook runs smoke tests on the test listener.

  7. Traffic shifts in a canary or linear pattern while health checks and test listeners validate the release.

  8. CloudWatch alarms on error rate and latency trigger an automatic rollback to the blue revision if breached.

Components and why they were chosen

ComponentWhat it doesWhy this choice
GitHub repository and branch protectionSource of truth, code review and required checks.Review and status checks are the control that stops unreviewed change reaching production.
GitHub Actions with OIDCRuns the pipeline and obtains short-lived cloud credentials.Eliminates stored cloud keys. Use Azure federated credentials in the same way.
Terraform (or CDK or Bicep)Declarative infrastructure with plan and apply.Plan output is reviewable. Choose one tool per platform to avoid drift between tools.
S3 backend with native lockingRemote state with versioning, encryption and an S3 lockfile (use_lockfile).Protects state, which can contain secrets. DynamoDB-based locking is deprecated from Terraform 1.11.
Amazon ECRPrivate image registry with scanning and lifecycle rules.Native to ECS and IAM, with immutable tags for traceability.
Amazon ECS blue/green deploymentsBuilt-in blue/green, canary and linear traffic shifting with lifecycle hooks and alarms.Automatic rollback is the main safety net. Existing CodeDeploy setups keep working, and AWS documents a migration path.
Checkov, Trivy or OPAPolicy-as-code for IaC.Catches public buckets and wildcard IAM before they are deployed. tfsec is now part of Trivy.
Image signing (Cosign or AWS Signer)Proves that an image came from the pipeline.Admission checks can refuse unsigned images.
SBOM and build provenanceCycloneDX or SPDX component list and a signed record of how each release was built.Answers “are we affected?” within minutes when a new vulnerability is announced.

Design decisions and trade-offs

Credentials

OIDC federation with branch and environment conditions.

Why. No secrets to leak or rotate.

Trade-off. Trust policy conditions must be precise or any workflow in the org could assume the role.

Release strategy

Blue/green with canary traffic shifting.

Why. Fast rollback and real-traffic validation.

Trade-off. Double capacity during rollouts and database changes must be backward compatible.

Environment promotion

Build once, promote the same image digest.

Why. What you tested is what you ship.

Trade-off. Configuration must be injected per environment, never baked in.

IaC apply

Apply from the pipeline only, humans read-only.

Why. Eliminates console drift and gives an audit trail.

Trade-off. Emergency changes need a break-glass process that is then reconciled in code.

Well-architected pillars

Security

OIDC, least-privilege deploy roles, scans as gates, signed artefacts, protected branches and environment approvals.

Reliability

Gradual traffic shifting, automated rollback and backward-compatible database migrations (expand then contract).

Performance

Cached builds, parallel jobs and a small test pyramid keep lead time in minutes.

Cost optimisation

Runner minutes, ECR storage and the temporary double capacity during blue/green.

Operational excellence

DORA metrics (deployment frequency, lead time, change failure rate, time to restore) tracked from the pipeline.

Sustainability

Cache dependencies, lifecycle old images and use ephemeral runners.

Network, identity and data

Networking

Self-hosted runners, if used, live in a private subnet with endpoints and no inbound access. Production deploy roles can only be assumed from the production environment in the workflow.

Identity and least privilege

Separate IAM roles per account and per purpose: plan (read-only), apply (scoped), deploy (ECS and CodeDeploy only). Trust policies pin repo, ref and environment claims. GitHub environments hold required reviewers.

Data and encryption

State files and build logs are encrypted and access-limited. Secrets are fetched at runtime from Secrets Manager or Key Vault, never written to logs or artefacts.

Security and compliance mapping

ControlHow this design addresses it
Application controlOnly signed pipeline-built images are deployable. Essential Eight application control principle.
Patch applicationsScheduled base-image rebuilds and dependency updates through automated pull requests. Essential Eight.
Restrict administrative privilegesHumans have read-only access to production. Essential Eight.
Change managementPull-request approval and plan output provide evidence for SACSF change control expectations.

Mappings show how the design supports each control. They are not certifications, and EITSAA does not claim IRAP assessment or compliance for any reference architecture.

Failure modes, targets and scaling

  • Target RTOMinutes to roll back a release
  • Target RPONot applicable to code; state is versioned
  • Scaling and limitsParallel pipelines per service. Watch runner concurrency and IAM role session limits.
Failure modeMitigation
Pipeline compromiseOIDC conditions, pinned third-party actions by SHA, least-privilege roles and approvals for production.
Bad release reaches usersCanary stage with alarms triggers automatic rollback.
Terraform state lost or lockedVersioned bucket, S3-native locking and a documented unlock procedure.
Compromised dependency or base imagePinned versions and digests, SBOM checked against new advisories, and reviewed update pull requests.
Incompatible database migrationExpand and contract pattern, with migrations run as a separate reversible step.

Observability and runbooks

  • Pipeline duration, failure rate and flaky test dashboard.
  • Deployment events annotated on service dashboards.
  • Alarm: any apply outside the pipeline (detected by CloudTrail principal).

Cost drivers and levers

CI minutes, artefact storage and extra capacity during blue/green.

  • Cache builds and use path filters.
  • Lifecycle rules in ECR.
  • Shorten canary windows for low-risk changes.
  • Use larger runners only where they cut total time.

Implementation and fit

Phased approach

  1. Get one service building and deploying from the pipeline with OIDC.
  2. Add scanning gates, plan on PR and environment approvals.
  3. Introduce blue/green and alarms.
  4. Roll the template out to the other services and retire manual deploys.

Anti-patterns to avoid

  • Long-lived access keys in CI secrets.
  • Deploying from developer laptops.
  • Rebuilding different images per environment.
  • Third-party actions referenced by mutable tags.

When to use it

  • Any team shipping to production more than occasionally.
  • Environments that need an audit trail of change.

When not to

  • One-off scripts with no ongoing ownership (the process cost will not pay back).

More in cloud platforms

Related insights

Discuss this architecture

Tell us your systems, constraints and timeline. We reply within one business day, and the initial conversation is free.