Cloud Deployment (AWS/GCP/Azure)

Chapter 9
CI/CD, DevSecOps and Release Engineering

Post Graduate Diploma in Full Stack Development
Cloud Deployment (AWS/GCP/Azure)   •   Post Graduate

9. CI/CD, DevSecOps and Release Engineering

Introduction and Context

Cloud deployment is no longer a final activity performed after software development has finished. In a modern delivery organization, source code, infrastructure definitions, configuration, security policies, tests, and operational procedures are continuously transformed into deployable and observable services. This transformation is governed by continuous integration, continuous delivery or deployment, DevSecOps, and release engineering.

Continuous integration (CI) helps teams integrate small changes frequently and verify them automatically. Continuous delivery (CD) ensures that validated changes are always ready for release, while continuous deployment automatically promotes approved changes into production. DevSecOps extends these practices by embedding security into planning, coding, building, testing, deployment, and operation. Release engineering provides the discipline for versioning, packaging, promotion, rollout, rollback, and governance.

For cloud practitioners, the pipeline is not merely a collection of scripts. It is a control system that connects developers, cloud platforms, artifact repositories, identity systems, security tools, and operational feedback. A poorly designed pipeline can accelerate insecure or defective software. A well-designed pipeline creates repeatability, traceability, rapid feedback, and controlled business change.

Learning Objectives

By the end of this chapter, learners should be able to:

  • distinguish CI, continuous delivery, continuous deployment, DevSecOps, and release engineering;
  • design a pipeline for source validation, building, testing, security scanning, artifact publication, and deployment;
  • implement representative workflows with GitHub Actions and AWS, Azure, or Google Cloud services;
  • select suitable rolling, blue-green, canary, and feature-flag release strategies;
  • apply rollback, promotion, approval, audit, and software supply-chain controls;
  • evaluate pipeline risks, delivery metrics, governance requirements, and organizational trade-offs.

From Code Commit to Reliable Release

A delivery pipeline converts an intended change into an operational outcome. A typical flow is:

1. A developer creates a branch and submits a pull request.

2. Automated checks validate formatting, dependencies, unit tests, and policy rules.

3. The application is built once and packaged as an immutable artifact, commonly a container image.

4. The artifact is scanned for vulnerabilities, secrets, license concerns, and provenance information.

5. The artifact is published to a registry and promoted between environments.

6. Infrastructure and application configuration are applied through controlled automation.

7. The deployment is verified using health checks, smoke tests, metrics, logs, and traces.

8. A progressive release exposes the change to an increasingly large population.

9. Evidence is recorded and the release is either completed, paused, or rolled back.

The phrase “build once, deploy many” is important. Rebuilding separately for testing and production can produce different binaries, dependencies, or timestamps. An immutable artifact should be tested and promoted without modification. Environment-specific values should be supplied through managed configuration and secret systems rather than by changing the artifact.

CI is primarily concerned with integration and rapid feedback. It normally includes compilation, unit tests, static analysis, dependency validation, and packaging. Continuous delivery adds deployment automation and ensures that a successful change can be released on demand. Continuous deployment removes a manual production release decision when organizational risk controls permit it. These are not synonymous: an organization may practise continuous delivery while retaining a human approval for production.

DevSecOps treats security as a shared engineering responsibility. Security specialists still provide expertise, but developers and platform engineers implement security controls in the normal workflow. This approach is often described as “shift left,” although effective security also requires controls at runtime and in production monitoring. A security check that occurs only at the end of a release is expensive and disruptive; a check that occurs too early without risk-based exceptions may block legitimate work. Mature programs combine early prevention with later verification.

Pipeline Architecture with GitHub Actions

GitHub Actions represents a workflow as YAML stored in a repository. A workflow responds to events such as pull requests, pushes, tags, schedules, or manually initiated dispatches. Jobs run on hosted or self-hosted runners, and steps execute commands or reusable actions. Jobs may run in parallel or depend on earlier jobs through explicit relationships.

A production-oriented workflow usually separates concerns into jobs such as `validate`, `test`, `build`, `scan`, `publish`, and `deploy`. Separation improves visibility and allows security or deployment jobs to have stricter permissions. A simplified conceptual workflow is:

```yaml

name: delivery

on:

pull_request:

push:

branches: [main]

permissions:

contents: read

id-token: write

jobs:

test:

runs-on: ubuntu-latest

steps:

  • uses: actions/checkout@v4
  • run: npm ci
  • run: npm test -- --coverage

build:

needs: test

runs-on: ubuntu-latest

steps:

  • uses: actions/checkout@v4
  • run: docker build --tag $IMAGE:${{ github.sha }} .
  • run: docker save $IMAGE:${{ github.sha }} > image.tar

scan:

needs: build

runs-on: ubuntu-latest

steps:

  • run: ./security-scan.sh image.tar

```

This illustration is intentionally incomplete. A real pipeline must authenticate to a cloud registry, preserve the artifact between jobs, apply image signing or provenance, and deploy through a controlled identity. Secrets should not be written directly into the workflow. Where supported, GitHub’s OpenID Connect (OIDC) federation allows a workflow to obtain short-lived cloud credentials based on its identity and repository context. This is safer than storing long-lived access keys as repository secrets.

Workflow security requires careful control of triggers and permissions. Pull requests from untrusted forks should not receive production credentials. The default token should have only the permissions required for the job. Third-party actions should be pinned to reviewed commit references rather than mutable tags when a high-assurance environment is required. Reusable workflows can standardize organizational controls, while environment protection rules can require reviewers, restrict branches, and record approvals.

Cloud-native equivalents can be used alongside GitHub Actions. AWS CodePipeline and CodeBuild, Azure Pipelines, and Google Cloud Build provide managed build and deployment services. Kubernetes environments may use Argo CD or Flux for GitOps-based reconciliation. The choice depends on existing skills, compliance requirements, integration needs, and the desired division between a source-control platform and a cloud provider.

Testing as a Delivery Control

A pipeline should provide rapid, trustworthy evidence rather than simply execute many tests. Unit tests examine small components and are normally fast. Integration tests verify communication with databases, queues, APIs, or cloud services. Contract tests check whether independently deployed services preserve agreed interfaces. End-to-end tests validate a business flow but are often slower and more fragile. Performance, resilience, accessibility, and infrastructure tests address risks that functional tests do not cover.

The test pyramid remains useful: many fast unit tests form the base, fewer integration tests occupy the middle, and a smaller number of carefully selected end-to-end tests form the top. The model is not a rigid numerical rule. The appropriate balance depends on architecture and failure consequences. Test results should be visible, reproducible, and associated with the exact commit and artifact.

Ephemeral environments can create temporary infrastructure for a pull request. They improve realism but introduce cost, data protection, cleanup, and network-isolation challenges. Production-like testing must never expose real personal data without authorization and appropriate controls. Test data should be synthetic or properly anonymized.

DevSecOps and Software Supply-Chain Security

Security controls in a delivery pipeline operate at several layers. Secret scanning detects credentials accidentally committed to source code. Static application security testing (SAST) examines source or intermediate code for patterns associated with vulnerabilities. Software composition analysis (SCA) identifies vulnerable or non-compliant open-source dependencies. Dynamic application security testing (DAST) tests a running service. Container and infrastructure-as-code scanners inspect images, manifests, Terraform, Kubernetes files, and cloud policies.

No scanner is perfect. False positives consume engineering attention, while false negatives create misplaced confidence. Findings should be prioritized using exploitability, reachability, exposure, asset value, and compensating controls. A critical vulnerability in an unused development dependency may require a different response from an exploitable vulnerability in a public authentication service.

Software supply-chain security also concerns the integrity of what is built. Useful controls include:

  • dependency lock files and approved repositories;
  • version pinning and controlled update automation;
  • minimal and reproducible build environments;
  • isolated runners and protected branches;
  • signed commits, container images, and release metadata;
  • a software bill of materials (SBOM);
  • provenance describing source, builder, dependencies, and process;
  • admission policies that reject untrusted or vulnerable artifacts.

The SLSA framework is commonly used as a vocabulary for increasing build and provenance assurance. The precise level of assurance depends on the threat model. A signed artifact is not automatically safe: signing proves control of a signing key, not the absence of vulnerabilities. Keys therefore require protected storage, rotation, restricted use, and incident procedures.

Secrets should be stored in services such as AWS Secrets Manager, AWS Systems Manager Parameter Store, Azure Key Vault, or Google Secret Manager. Applications should receive only the secrets needed for their function. Rotation, access logging, expiration, and emergency revocation are operational requirements, not optional enhancements.

Artifact Management and Promotion

An artifact repository provides a controlled location for packages, container images, charts, and other release objects. Examples include Amazon Elastic Container Registry, Azure Container Registry, and Google Artifact Registry. Repositories should use immutable tags or, preferably, content digests. A tag such as `latest` is convenient for experimentation but weak as a production reference because its meaning can change.

Artifact promotion means moving the same artifact through development, staging, and production rather than rebuilding it for each environment. Metadata should identify the source commit, build workflow, dependency set, test results, and approving party. Retention policies should balance auditability against storage cost. When an artifact must be withdrawn, the organization should preserve sufficient evidence to determine where it was deployed and what systems depend on it.

Infrastructure as code extends these principles to cloud resources. Pull requests can validate Terraform plans, CloudFormation templates, Azure Bicep files, or deployment manifests. State files require locking, backup, encryption, and access control. A pipeline should show planned infrastructure changes before applying them, especially where changes affect networks, identity, databases, or data retention.

Release Strategies and Risk Management

A release strategy determines how a new version reaches users and how failure is detected.

Rolling deployment replaces instances gradually. It uses resources efficiently and is natural for Kubernetes or managed instance groups. However, old and new versions coexist, so backward-compatible APIs and database migrations are essential. A defective release may affect users before it is fully recognized.

Blue-green deployment maintains two environments. The blue environment serves current traffic and the green environment contains the candidate release. After validation, a load balancer or routing mechanism switches traffic. Rollback can be rapid, provided the old environment remains available and data changes are compatible. The principal cost is operating duplicate capacity.

Canary deployment sends a small percentage of traffic to the new version before broader exposure. It is especially powerful when automated metrics compare error rate, latency, saturation, and business outcomes between versions. A canary without objective promotion and abort criteria is merely a partial deployment, not a controlled experiment.

Feature flags separate code deployment from feature activation. A feature can be enabled for internal users, a region, a customer segment, or a percentage of traffic. Flags support experimentation and rapid disablement, but they create configuration complexity and technical debt. Every flag should have an owner, purpose, default behavior, expiry date, and audit trail.

Database changes complicate rollback. Destructive schema changes should normally be separated into additive, migration, and cleanup phases. The expand-and-contract pattern first adds structures compatible with both versions, migrates data, changes application usage, and removes obsolete structures only after the old version is no longer required. Rolling back application code does not necessarily roll back a database safely.

Observability, Approval, and Rollback

A deployment is successful only when the service remains healthy for users. Pipeline checks should therefore connect to observability systems. Technical indicators include request error rate, latency percentiles, resource saturation, restart frequency, queue depth, and dependency failures. Business indicators may include successful transactions, conversion, payment completion, or support incidents.

A service-level objective (SLO) can provide a release guardrail. For example, a canary may be paused if its error rate exceeds the baseline by a defined margin for a specified period. Thresholds must account for statistical noise and traffic volume. Automated rollback is appropriate for well-understood failure signals, but it should not conceal systemic problems or cause repeated deployment loops.

Rollback can mean restoring the previous application artifact, switching traffic to a previous environment, disabling a feature flag, or reverting configuration. It is not always possible to undo an irreversible data migration. Teams should practise rollback through game days and document who can authorize emergency action. A post-incident review should examine both the defect and the controls that allowed it to reach users.

Release Engineering as an Organizational Discipline

Release engineering coordinates technical automation with organizational decision-making. It defines versioning conventions, branching policies, release calendars where necessary, environment ownership, change records, approval thresholds, and emergency procedures. The goal is not to maximize deployment frequency at any cost. The goal is to make change frequent when safe, visible when risky, and reversible whenever possible.

Useful delivery metrics include deployment frequency, lead time from commit to production, change failure rate, and time to restore service. These metrics are most valuable as indicators for improvement rather than as targets for individual teams. If teams are rewarded only for deployment frequency, they may release low-value changes or weaken safeguards. Metrics should be interpreted with quality, security, reliability, and customer outcomes.

Segregation of duties may be required in regulated environments, but excessive manual approval creates queues and encourages bypass behavior. Risk-based governance is more effective: low-risk, well-tested changes may flow automatically, while identity, financial, data-retention, or network changes require additional review. Audit records should show the source commit, artifact digest, tests, scan results, deployment identity, approvals, and resulting environment.

Illustrative Case Study: A Canary Release for a Cloud Payment Service

Background

A fictional online retailer operates a containerized payment service on Kubernetes. The service is built through GitHub Actions and deployed to a managed cloud cluster. The retailer experiences frequent peak traffic and cannot tolerate a prolonged payment outage.

Situation and Problem

A new release improves payment-provider integration but changes timeout handling. A conventional rolling deployment would gradually replace all instances, yet an error could affect a large number of transactions before detection. The organization also needs evidence that the production artifact is identical to the tested artifact.

Analysis

The team identifies four risks: incorrect timeout behavior, incompatible configuration, supply-chain tampering, and an unsafe database change. It defines success indicators: payment error rate, p95 latency, provider timeout rate, and completed-payment percentage. It also establishes an abort threshold relative to the stable version and determines that the feature can be disabled without redeploying.

Approach and Solution

A pull request runs unit, integration, contract, SAST, SCA, secret, and infrastructure scans. The workflow builds one image tagged with the commit digest, generates an SBOM, signs the image using a protected signing service, and publishes it to the cloud registry. A staging deployment runs smoke and migration-compatibility tests.

Production deployment creates a canary workload using the same image digest. The service mesh routes 5 percent of eligible traffic to it. Automated analysis compares the canary with the stable workload for fifteen minutes. If indicators remain within policy, traffic increases to 25 percent and then 100 percent. If thresholds are exceeded, routing returns to the stable workload and the feature flag disables the new timeout behavior. Database changes follow the expand-and-contract pattern.

Outcome

In the illustrative scenario, the canary reveals a higher provider-timeout rate. The pipeline pauses promotion, routing returns to the stable version, and the team investigates without a broad customer impact. After correcting the timeout configuration, the same artifact-building and testing controls are repeated for a new commit. The release is later promoted successfully.

Learning Points

The case demonstrates that release safety depends on more than deployment commands. Immutable artifacts, provenance, progressive exposure, meaningful metrics, feature flags, compatible data changes, and rehearsed rollback work together. Canary deployment is effective only when the organization can observe and act on evidence.

Challenges, Limitations, and Common Mistakes

Pipeline implementation can fail through excessive complexity. A workflow with dozens of loosely governed tools may produce slow feedback and unclear ownership. Teams sometimes make every scan blocking, even when findings are irrelevant or untriaged. Conversely, permanently ignoring findings creates security debt.

Other common mistakes include storing long-lived cloud keys in repositories, exposing secrets in logs, using privileged build runners, trusting mutable image tags, rebuilding for every environment, deploying without health checks, and treating a successful process exit as proof of application health. Inadequate test data isolation can create privacy violations. Uncontrolled feature flags can leave abandoned code paths and inconsistent user experiences.

Self-hosted runners require special care because they may retain credentials, source code, or build artifacts. Dependency updates can introduce malicious or incompatible code, so automated updates need review and testing. Cloud-provider lock-in is another consideration: managed services reduce operational effort but may complicate migration and cross-cloud consistency.

Governance, Ethics, and Compliance

Delivery automation has professional and ethical consequences. A pipeline can deploy changes affecting financial transactions, personal data, accessibility, or public services. Engineers must ensure that speed does not override informed risk assessment. Access should follow least privilege, and production actions should be attributable to a person or controlled workload identity.

Compliance requirements may cover change approval, audit retention, vulnerability remediation, data residency, separation of duties, and incident reporting. Compliance should be implemented as verifiable controls rather than as manual paperwork added after deployment. Policy-as-code can check encryption, network exposure, approved regions, image provenance, and required labels. Automated policy decisions should still provide an appeal or exception process with accountable ownership.

Current Developments

Several developments are shaping release engineering. GitOps uses a version-controlled desired state and a reconciler to apply changes, improving auditability and drift detection. Policy-as-code enables security and governance rules to run in pull requests and admission controllers. SBOM exchange and artifact attestations are becoming more common as organizations respond to supply-chain threats.

Progressive delivery platforms increasingly automate canary analysis, experiment assignment, and rollback. AI-assisted development can generate code and tests, but generated output requires the same review, scanning, licensing analysis, and provenance controls as human-written code. AI may help identify anomalous deployment metrics, yet organizations should avoid treating probabilistic recommendations as an independent safety control.

Best-Practice Design Principles

A robust cloud delivery system generally follows these principles:

  • keep workflows versioned, reviewable, and modular;
  • grant each job the minimum permissions required;
  • use short-lived federated credentials instead of stored cloud keys;
  • build once, record provenance, sign where appropriate, and promote immutable artifacts;
  • combine fast tests with risk-based security and compliance gates;
  • deploy progressively when failure consequences justify it;
  • define observable promotion and rollback criteria before release;
  • design database changes for coexistence of versions;
  • keep feature flags temporary, documented, and audited;
  • measure delivery performance together with reliability, security, and customer outcomes;
  • rehearse restoration, rollback, and credential compromise procedures.

Chapter Summary

CI/CD provides the automation and feedback required to integrate, validate, package, and release software reliably. DevSecOps embeds security throughout the lifecycle, while release engineering governs artifacts, environments, approvals, progressive exposure, rollback, and evidence. GitHub Actions can coordinate testing, cloud authentication, image creation, scanning, publication, and deployment, but its security depends on permissions, runner isolation, secret management, and trustworthy actions.

Immutable artifacts, SBOMs, provenance, signing, and policy-as-code strengthen the software supply chain. Rolling, blue-green, canary, and feature-flag strategies offer different balances of cost, speed, complexity, and rollback capability. Observability and explicit release criteria turn deployment into an evidence-based process. At postgraduate level, the central lesson is that delivery performance is socio-technical: tools matter, but architecture, governance, organizational incentives, and professional judgment determine whether automation produces safe outcomes.

Key Terms

CI: Continuous integration; frequent integration of code with automated validation.

Continuous delivery: A practice in which validated software remains ready for on-demand release.

Continuous deployment: Automatic release of validated changes to production.

DevSecOps: Integration of security responsibilities and controls throughout software delivery and operation.

Release engineering: The discipline of planning, packaging, promoting, deploying, and governing releases.

Artifact: A versioned deployable output such as a package, container image, or chart.

Immutable artifact: An artifact whose contents are not changed after creation.

OIDC federation: Short-lived identity federation allowing a workflow to obtain cloud credentials without stored long-lived keys.

SAST: Static application security testing performed on source or intermediate code.

DAST: Dynamic security testing of a running application.

SCA: Software composition analysis of third-party dependencies.

SBOM: Software bill of materials listing software components and dependencies.

Provenance: Evidence describing how, from what source, and by which builder an artifact was produced.

Blue-green deployment: Release strategy using two environments and switching traffic between them.

Canary deployment: Gradual exposure of a release to a small initial user or traffic group.

Rolling deployment: Incremental replacement of old instances with new instances.

Feature flag: Runtime-controlled switch that enables or disables functionality independently of deployment.

Rollback: Action that returns service behavior to a previous safe version or configuration.

SLO: Service-level objective defining a target for an aspect of service reliability.

GitOps: Operational model in which version-controlled desired state is reconciled automatically into environments.

Review Questions

Short Answer Questions

1. Differentiate continuous delivery from continuous deployment.

2. Why is “build once, deploy many” important?

3. What purpose does an SBOM serve?

4. State two advantages and one limitation of blue-green deployment.

5. Why should feature flags have an expiry date?

Long Answer Questions

1. Explain how a GitHub Actions workflow can progress from pull-request validation to production deployment. Include security and identity controls.

2. Discuss the role of DevSecOps in software supply-chain security, including scanning, provenance, signing, and artifact management.

3. Compare rolling, blue-green, and canary deployment strategies with respect to cost, observability, rollback, and compatibility.

4. Explain how database migration design affects deployment and rollback decisions.

5. Describe a governance model that balances automated delivery with approval, audit, and regulatory requirements.

Analytical / Application Questions

1. A canary release has normal latency but a 4 percent increase in failed business transactions. What additional evidence would you examine, and what release action would you recommend?

2. A team rebuilds its container separately for staging and production and uses the `latest` tag. Analyze the risks and propose a corrected artifact strategy.

3. Design a release plan for a financial service that requires minimal downtime, auditable approvals, rapid rollback, and protection against leaked cloud credentials. Justify your choices.

22. Multiple Choice Questions with Answers

Question 1

Which practice best implements “build once, deploy many”?

A. Rebuilding the application separately in every environment

B. Promoting the same immutable artifact through environments

C. Using the latest mutable image tag in production

D. Changing application binaries during deployment

Correct Answer: B. Promoting the same immutable artifact through environments

Question 2

What is the principal security advantage of OIDC federation in GitHub Actions?

A. It eliminates the need for source-code review

B. It provides permanent administrator credentials to workflows

C. It enables short-lived cloud credentials without stored long-lived keys

D. It encrypts all application data automatically

Correct Answer: C. It enables short-lived cloud credentials without stored long-lived keys

Question 3

Which release strategy initially exposes a new version to a small percentage of traffic?

A. Canary deployment

B. Blue-green deployment

C. Big-bang deployment

D. Full replacement deployment

Correct Answer: A. Canary deployment

Question 4

A production database must support both the old and new application versions during rollout. Which approach is most appropriate?

A. Immediate destructive schema replacement

B. Expand-and-contract migration

C. Rebuilding the database from scratch during deployment

D. Disabling database validation

Correct Answer: B. Expand-and-contract migration

Question 5

What does an SBOM primarily provide?

A. A list of software components and dependencies in an artifact

B. A record of production user passwords

C. A replacement for runtime monitoring

D. A guarantee that the software contains no vulnerabilities

Correct Answer: A. A list of software components and dependencies in an artifact

Question 6

Which control most directly reduces the risk of a workflow modifying unrelated cloud resources?

A. Using a mutable image tag

B. Granting the workflow least-privilege permissions

C. Increasing the number of deployment stages

D. Disabling audit logs

Correct Answer: B. Granting the workflow least-privilege permissions

Question 7

A canary shows increased payment failures but normal CPU utilization. What is the best immediate action?

A. Promote it to all users because infrastructure metrics are normal

B. Ignore business metrics until the next release

C. Pause or abort promotion and investigate the business failure signal

D. Increase runner capacity

Correct Answer: C. Pause or abort promotion and investigate the business failure signal

Question 8

Which statement about feature flags is most accurate?

A. They remove the need for testing

B. They permanently eliminate deployment risk

C. They separate feature activation from code deployment but create configuration debt

D. They are useful only for database migrations

Correct Answer: C. They separate feature activation from code deployment but create configuration debt

Question 9

Why are mutable tags such as `latest` weak production references?

A. They cannot be stored in registries

B. Their contents can change while the reference remains the same

C. They always contain vulnerable dependencies

D. They prevent container scanning

Correct Answer: B. Their contents can change while the reference remains the same

Question 10

Which evidence is most useful for determining whether a release can be promoted safely?

A. Only the workflow completion message

B. Only the number of files changed

C. Tests, security results, artifact provenance, and health and business metrics

D. The developer’s estimate of release risk

Correct Answer: C. Tests, security results, artifact provenance, and health and business metrics

Cloud Deployment (AWS/GCP/Azure)
Chapter 9 of 15